gpt4 book ai didi

installation - 如何从 CDROM(ISO 镜像)启动以使用 virsh 安装 guest 操作系统

转载 作者:行者123 更新时间:2023-12-05 01:44:22 46 4
gpt4 key购买 nike

2017 年 10 月 4 日更新:请参阅下面我的回答。感谢 DanielB,因为如果没有 Daniel 的帮助我无法解决问题,所以我将接受他的回答而不是我自己的回答。


我是 libvirt 和系统管理方面的新手,所以如果我问的是愚蠢的问题,请原谅我,尽管我事先已经尝试做尽可能多的功课。

我的问题是:如何在使用 virsh 创建虚拟机后立即从 CDROM 启动以安装客户操作系统?

我正在使用 Ubuntu Desktop 14.04,virsh 1.2.2。

当我使用“virt-install”并将 ISO 文件路径作为其“--cdrom”参数传递时,我可以成功调出 virt-viewer 窗口,该窗口允许我完成 guest 操作系统安装。

据我所知,我还可以使用 XML 定义创建 VM,我转储了使用“virt-install”创建的 VM 的 XML 定义。然后我希望在启动 VM 时会自动显示“virt-viewer”窗口,以便我可以安装 guest 操作系统。但它没有。

下面是我的 VM 的 XML 定义。

如果我启用加载程序行,正如我在下面标记为“可疑”的那样,我会收到一条错误消息“错误:内部错误:无法加载 AppArmor 配置文件‘libvirt-1092d51d-3b66-46a2-bf9b-71e13dc91799’” .我这样做是因为我正在尝试 libvirt's document here 中给出的示例.

但是,如果我禁用“loader”行,并运行 virsh create def_domain_test.xml,域可以成功创建并显示为“running”,但是 virt-未显示查看器窗口,因此我无法在 VM 上安装 guest 操作系统

谁能帮我解决这个问题? 我不明白为什么“virt-install”可以启动 virt-viewer 而我的 XML 定义却不能。我可能错误配置了域 XML 定义,但即使我尝试阅读尽可能多的文档,我也无法找出我错在哪个特定部分。

如有需要,请随时询问更多详情。

<!-- Let's call this file 'def_domain_test.xml' -->
<domain type='kvm'>
<name>vm_c2</name>
<memory unit='KiB'>2097152</memory>
<currentMemory unit='KiB'>2097152</currentMemory>
<vcpu placement='static'>1</vcpu>
<os>
<type arch='x86_64' machine='pc-i440fx-trusty'>hvm</type>
<!-- Next line is suspicious! -->
<!-- <loader readonly='yes' secure='no' type='rom'>/usr/lib/xen-4.4/boot/hvmloader</loader> -->
<boot dev='cdrom'/>
<boot dev='hd'/>
</os>
<features>
<acpi/>
<apic/>
<pae/>
</features>
<clock offset='utc'/>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>restart</on_crash>
<devices>
<emulator>/usr/bin/kvm-spice</emulator>

<!-- Here is the hard drive that doesn't have OS installed. -->
<disk type='file' device='disk'>
<driver name='qemu' type='raw'/>
<source file='/home/me/me/testing/vm/pool/mvs_vol_c2'/>
<target dev='hda' bus='ide'/>
<address type='drive' controller='0' bus='0' target='0' unit='0'/>
</disk>

<!-- Here is the Ubuntu ISO. -->
<disk type='file' device='cdrom'>
<driver name='qemu' type='raw'/>
<source file='/home/me/me/testing/vm/ubuntu-14.04.5-server-amd64.iso'/>
<target dev='hdc' bus='ide'/>
<readonly/>
<alias name='ide0-1-0'/>
<address type='drive' controller='0' bus='1' target='0' unit='0'/>
</disk>

<controller type='usb' index='0'>
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
</controller>
<controller type='pci' index='0' model='pci-root'/>
<controller type='ide' index='0'>
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
</controller>
<interface type='network'>
<source network='default'/>
<model type='rtl8139'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
</interface>
<serial type='pty'>
<target port='0'/>
</serial>
<console type='pty'>
<target type='serial' port='0'/>
</console>
<input type='mouse' bus='ps2'/>
<input type='keyboard' bus='ps2'/>
<graphics type='vnc' port='-1' autoport='yes'/>
<video>
<model type='cirrus' vram='9216' heads='1'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
</video>
<memballoon model='virtio'>
<address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
</memballoon>
</devices>
</domain>

最佳答案

virsh是一个非常低级别的工具,其命令直接映射到各个 libvirt API 调用。 virt-install 完成的安装将调用许多 API 来完成它的工作。所以只需获取已安装客户机的最终 XML 并将其传递给 virsh define不等价。

首先,virt-install通常会更改 XML - 它首先创建一个临时客户,将一个适合从 CDROM 启动的 XML 文档,完成后它将更改 XML 以改为从磁盘启动。 virt-install将手动启动 virt-viewer显示控制台,这不是什么virsh

那个特别的<loader>行不应该与 KVM 一起使用 - 它只与 Xen 相关 - 通过使用你告诉 KVM 运行 Xen paravirt 代码作为其 BIOS 而不是 SeaBIOS - 这肯定会崩溃和烧毁。

如果您使用 '--debug' arg 到 virt-install您将看到它在每个步骤中所做的详细信息。您还可以设置 LIBVIRT_LOG_FILTERS=1:libvirtLIBVIRT_LOG_OUTPUTS=1:stderr如果您想查看每个 libvirt API 调用的详细信息。

关于installation - 如何从 CDROM(ISO 镜像)启动以使用 virsh 安装 guest 操作系统,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46552266/

46 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com