Qemu kvm_qemu详细教程

Qemu kvm_qemu详细教程重新创建vm修改虚拟机的xml文件virshshutdown原来的虚拟机virshundefine原来的虚拟机virshdefine新的xml文件,创建虚拟机virshstart虚拟机

大家好,又见面了,我是你们的朋友全栈君。如果您正在找激活码,请点击查看最新教程,关注关注公众号 “全栈程序员社区” 获取激活教程,可能之前旧版本教程已经失效.最新Idea2022.1教程亲测有效,一键激活。

Jetbrains全系列IDE使用 1年只要46元 售后保障 童叟无欺

virsh

重新创建vm

修改虚拟机的xml文件
virsh shutdown 原来的虚拟机
virsh undefine 原来的虚拟机
virsh define 新的 xml文件,创建虚拟机
virsh start 虚拟机

virsh dump

如果是openstack的环境,virsh dump –file 指定文件路径后,生成的文件,不是在 指定路径而是在:
/var/lib/docker/overlay2/****/diff/root

可以用来dump vm的 memory,是不是可以用gdb 来做dump;

qemu-kvm

qemu manual : https://www.mankier.com/1/qemu

-smp

-smp [[cpus=]n][,maxcpus=maxcpus][,sockets=sockets][,dies=dies][,clusters=clusters][,cores=cores][,threads=threads]
模拟SMP的系统,虚拟器初始之后,模拟出n个CPU。如果模拟的板子支持CPU热拔插,maxcpus就是在系统运行时,最多可以添加到多少个CPU。如果cpus和maxcpus两个参数没有设置,会根据相关的其他参数来做计算,计算的值就是两个参数的值。When only one of them is given then the omitted one will be set to its counterpart’s value. Both parameters may be specified, but the maximum number of CPUs must be equal to or greater than the initial CPU count. Product of the CPU topology hierarchy must be equal to the maximum number of CPUs. Both parameters are subject to an upper limit that is determined by the specific machine type chosen.

To control reporting of CPU topology information, values of the topology parameters can be specified. Machines may only support a subset of the parameters and different machines may have different subsets supported which vary depending on capacity of the corresponding CPU targets. So for a particular machine type board, an expected topology hierarchy can be defined through the supported sub-option. Unsupported parameters can also be provided in addition to the sub-option, but their values must be set as 1 in the purpose of correct parsing.

Either the initial CPU count, or at least one of the topology parameters must be specified. The specified parameters must be greater than zero, explicit configuration like "cpus=0" is not allowed. Values for any omitted parameters will be computed from those which are given.

For example, the following sub-option defines a CPU topology hierarchy (2 sockets totally on the machine, 2 cores per socket, 2 threads per core) for a machine that only supports sockets/cores/threads. Some members of the option can be omitted but their values will be automatically computed:

-smp 8,sockets=2,cores=2,threads=2,maxcpus=8

接下来的参数,就是CPU拓扑结构(2个sockets,每个socket两个dies,每个die有两个core,每个core有2个threads)
The following sub-option defines a CPU topology hierarchy (2 sockets totally on the machine, 2 dies per socket, 2 cores per die, 2 threads per core) for PC machines which support sockets/dies/cores/threads. Some members of the option can be omitted but their values will be automatically computed:

-smp 16,sockets=2,dies=2,cores=2,threads=2,maxcpus=16

The following sub-option defines a CPU topology hierarchy (2 sockets totally on the machine, 2 clusters per socket, 2 cores per cluster, 2 threads per core) for ARM virt machines which support sockets/clusters /cores/threads. Some members of the option can be omitted but their values will be automatically computed:

-smp 16,sockets=2,clusters=2,cores=2,threads=2,maxcpus=16

Historically preference was given to the coarsest topology parameters when computing missing values (ie sockets preferred over cores, which were preferred over threads), however, this behaviour is considered liable to change. Prior to 6.2 the preference was sockets over cores over threads. Since 6.2 the preference is cores over sockets over threads.

For example, the following option defines a machine board with 2 sockets of 1 core before 6.2 and 1 socket of 2 cores after 6.2:

-smp 2

创建vm,基于vmlinz

-kernel bzImage Use bzImage as kernel image. The kernel can be either a Linux kernel or in multiboot format.
-append cmdline Use cmdline as kernel command line
-initrd file Use file as initial ram disk.
-name name Sets the name of the guest. This name will be displayed in the SDL window caption. The name will also be used for the VNC server. Also optionally set the top visible process name in Linux.

-serial stdio 在command 参数里指定 console=ttyS0,就可以打印出来了。debug kernel/系统启动的问题时,就用这个参数就可用。不需要其他的

-m 指定内存大小

/usr/libexec/qemu-kvm -kernel vmlinuz-4.18.0-240.15.1.el8_3.x86_64 -initrd js.lcprhel.image -append “root=/dev/ram rw root_size=300M lcpbrdtype=kvm console=ttyS0” -serial stdio -m 512

错误总结

Failed to create chardev

char device redirected to /dev/pts/12 (label charserial0)
qemu-kvm: -chardev pipe,id=charchannel0,path=/tmp/FROM-abc: Failed to create chardev
这个是什么原因:
chardev/char-pty.c
char_pty_open
error_report(“char device redirected to %s (label %s)”, pty_name, chr->label);
为什么会打印这个错误:https://gitlab.com/qemu-project/qemu/-/commit/6ade45f2ac936114d82a18ed10df1fb717f4a584
Why is it even printed? No other ChardevClass::open() prints anything on success. It’s because you need to know PTY_NAME to actually use this char device, e.g. like e.g. “socat STDIO,cfmakeraw FILE:PTY_NAME” to use the monitor’s readline interface. You can get PTY_NAME with “info chardev” (a.k.a. query-chardev for QMP), but only if you already have a monitor.

之后再怎么处理? 有log文件,可用查看log文件,在哪里?

ramdisk 的大小超过80M,boot failure

/usr/libexec/qemu-kvm -kernel vmlinuz-4.18.0-240.15.1.el8_3.x86_64 -initrd js.lcprhel.image -append “root=/dev/ram rw root_size=300M lcpbrdtype=kvm console=ttyS0” -serial stdio -m 512
如果ramdsik的大小大于80M,需要指定的内存大一点。-m 默认是128M
https://stackoverflow.com/questions/42872992/qemu-fails-to-load-when-my-initrd-cpio-is-large-80-mb
这个有什么可用供参考的log吗?

指定串口速率

/usr/libexec/qemu-kvm -kernel vmlinuz-4.18.0-240.15.1.el8_3.x86_64 -initrd js.lcprhel.image -append “root=/dev/ram rw root_size=300M lcpbrdtype=kvm console=ttyS0,115200n81” -serial stdio -m 512
指定串口的速率,这个也比较重要;不如串口不能输入命令

qemu-img

qemu-img可以离线新建,转换,修改images。It can handle all image formats supported by QEMU.
警告,绝不要在image被虚拟机或者其他进程使用三修改它。这样会导致image损坏。同时在这种情况下也不要查询image,可能导致image的状态不一致。

info

info [–object objectdef] [–image-opts] [-f fmt] [–output=ofmt] [–backing-chain] [-U] filename
查询磁盘image文件的信息。主要是查看占有的磁盘空间,原因是所占用的磁盘空间可能和显示的大小不一样。
Use it in particular to know the size reserved on disk which can be different from the displayed size. If VM snapshots are stored in the disk image, they are displayed too.
If a disk image has a backing file chain, information about each disk image in the chain can be recursively enumerated by using the option “–backing-chain”.
For instance, if you have an image chain like:
base.qcow2 <- snap1.qcow2 <- snap2.qcow2
To enumerate information about each disk image in the above chain, starting from top to base, do:
qemu-img info –backing-chain snap2.qcow2
The command can output in the format ofmt which is either “human” or “json”. The JSON output is an object
of QAPI type “ImageInfo”; with “–backing-chain”, it is an array of “ImageInfo” objects.

       "--output=human" reports the following information (for every image in the chain):
       image
           The image file name

file format

The image format: 这些都是什么format,格式,奇奇怪怪的格式。
Supported formats: blkdebug blklogwrites blkreplay blkverify copy-on-read file ftp ftps gluster host_cdrom host_device http https iscsi iser luks nbd null-aio null-co nvme qcow2 quorum raw rbd ssh throttle vhdx vmdk vpc

virtual size

The size of the guest disk

disk size

How much space the image file occupies on the host file system (may be shown as 0 if this information is unavailable, e.g. because there is no file system)

参考

https://abelsu7.top/2019/03/28/kvm-review/

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/169800.html原文链接:https://javaforall.net

(0)
上一篇 2022年8月11日 下午10:36
下一篇 2022年8月11日 下午10:46


相关推荐

  • backbone中文_backbone公司

    backbone中文_backbone公司代码下载地址:下载地址支持的backbone为Ghostnet、Shufflenetv2、Mobilenetv3Small、EagleEye、EfficientNetLite-0、PP-LCNet-1x、SwinTrans-YOLOv5Requirementspipinstall-rrequirements.txtMulti-BackboneSubstitutionforYOLOs1、BaseModelTrainonVisdroneDataSet(Inp

    2022年8月16日
    10
  • 解决 1080端口已被占用

    解决 1080端口已被占用转载自https://blog.csdn.net/longintchar/article/details/79680589问题的提出【实验环境】:Win764bit也许你会碰到以下错误:本文给出2种解决方案。方案一既然说端口已被占用,那就需要找出是哪个程序占用了1080端口。打开cmd.exe,输入命令:netstat-aon|findstr”1080″1最后一列就…

    2025年9月24日
    4
  • intellij idea输出语句快捷键_常用快捷键大全图片

    intellij idea输出语句快捷键_常用快捷键大全图片其他的快捷键还有很多,象Ctrl+G(跳转到指定行)、Ctrl+F4(关闭当前编辑页面)、Ctrl+F(搜索)等等,这些快捷键由于是各个编辑器都会提供的,而且定义的键位也都差不多,就没什么可说的了;Alt+回车导入包,自动修正Ctrl+N 查找类Ctrl+Shift+N查找文件Ctrl+Alt+L 格式化代码Ctrl+Alt+O优化导入的类和包Alt+Ins

    2022年8月28日
    7
  • webpack的devtool[通俗易懂]

    webpack的devtool[通俗易懂]这里以环境分类为分析方向1.对开发环境eval-每个模块都使用eval()执行,并且都有//@sourceURL。此选项会非常快地构建。主要缺点是,由于会映射到转换后的代码,而不是映射到原始代码(没有从loader中获取sourcemap),所以不能正确的显示行数。eval-source-map-每个模块使用eval()执行,并且sourcem…

    2022年10月5日
    3
  • java和python的就业前景_Java和Python哪个发展前景好?老男孩教育

    java和python的就业前景_Java和Python哪个发展前景好?老男孩教育对薪资不满意 担心自己以后不好找工作 不少人都会选择参加培训 转行 IT 行业 当然很多想要转行 IT 的人 都会犹豫选择哪门编程语言学习比较好 Python Java 大数据作为比较热门行业技术 不少人都很疑惑转行学 Java Python 大数据哪个好 今天老男孩 IT 教育北京校区的老师为大家详细的说说吧 Java Java 可以从事 web 开发 大数据开发 安卓开发 服务器开发 桌面开发以及游戏开发等 Ja

    2026年3月20日
    2
  • 牛逼plus的springboot+maven车牌识别开源系统

    牛逼plus的springboot+maven车牌识别开源系统

    2020年11月13日
    203

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号