virsh 命令的问题

发布于 2024-11-09 01:33:59 字数 3495 浏览 0 评论 0原文

我一直在尝试使用 virsh attah-disk 附加 qcow2 文件作为附加存储源。我使用的语法是(来自互联网):

virsh attach-disk --driver file vm2 disk2.qcow2 hdc

如果虚拟机正在运行或暂停,则显示:

error: this function is not supported by the hypervisor: disk bus 'ide' cannot be hotplugged.

如果虚拟机关闭,则显示:

error: Requested operation is not valid: cannot attach device on inactive domain

我不确定 hdc 参数。我尝试过将 Attach-device 函数也与 xml 文件一起使用:

<disk type="file" device="disk">
    <driver name="file"/>
    <source file="/gfs1/disk2.qcow2"/>
    <target dev="hdc"/>
</disk>

但这也表明:

error: Failed to attach device from /gfs1/disk2tovm2.xml
error: this function is not supported by the hypervisor: disk bus 'ide' cannot be hotplugged.

我查看了很多示例,但它们都不起作用,并且都具有几乎相同的语法。 如果有人能帮我找出错误。

VM完整配置文件

root@blade1:/vms# virsh dumpxml vm2
<domain type='kvm' id='33'>
  <name>vm2</name>
  <uuid>70affd5d-af95-72c5-2d96-c131f46409b6</uuid>
  <description>--autostart</description>
  <memory>1048576</memory>
  <currentMemory>1048576</currentMemory>
  <vcpu>2</vcpu>
  <os>
    <type arch='i686' machine='pc-0.14'>hvm</type>
    <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</emulator>
    <disk type='file' device='disk'>
      <driver name='qemu' type='qcow2'/>
      <source file='/vms/vm2.qcow2'/>
      <target dev='vda' bus='virtio'/>
      <alias name='virtio-disk0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
    </disk>
    <interface type='bridge'>
      <mac address='52:54:00:5e:98:e4'/>
      <source bridge='br0'/>
      <target dev='vnet0'/>
      <alias name='net0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
    </interface>
    <serial type='pty'>
      <source path='/dev/pts/0'/>
      <target port='0'/>
      <alias name='serial0'/>
    </serial>
    <console type='pty' tty='/dev/pts/0'>
      <source path='/dev/pts/0'/>
      <target type='serial' port='0'/>
      <alias name='serial0'/>
    </console>
    <input type='mouse' bus='ps2'/>
    <graphics type='vnc' port='6900' autoport='no' listen='0.0.0.0'/>
    <video>
      <model type='cirrus' vram='9216' heads='1'/>
      <alias name='video0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
    </video>
    <memballoon model='virtio'>
      <alias name='balloon0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
    </memballoon>
  </devices>
  <seclabel type='dynamic' model='apparmor'>
    <label>libvirt-70affd5d-af95-72c5-2d96-c131f46409b6</label>
    <imagelabel>libvirt-70affd5d-af95-72c5-2d96-c131f46409b6</imagelabel>
  </seclabel>
</domain>

I have been trying to use virsh attah-disk to attach a qcow2 file as additional storage source. The syntax i am using is (from internet):

virsh attach-disk --driver file vm2 disk2.qcow2 hdc

If the vm is running or paused it shows:

error: this function is not supported by the hypervisor: disk bus 'ide' cannot be hotplugged.

If the vm is shutdown it shows:

error: Requested operation is not valid: cannot attach device on inactive domain

I am not sure about the hdc parameter. I have tried using attach-device function also with xml file as:

<disk type="file" device="disk">
    <driver name="file"/>
    <source file="/gfs1/disk2.qcow2"/>
    <target dev="hdc"/>
</disk>

But this also shows:

error: Failed to attach device from /gfs1/disk2tovm2.xml
error: this function is not supported by the hypervisor: disk bus 'ide' cannot be hotplugged.

I looked at many examples but none of them worked and all had almost the same syntax.
If someone could help me figure out the error.

COMPLETE CONFIGURATION FILE OF VM

root@blade1:/vms# virsh dumpxml vm2
<domain type='kvm' id='33'>
  <name>vm2</name>
  <uuid>70affd5d-af95-72c5-2d96-c131f46409b6</uuid>
  <description>--autostart</description>
  <memory>1048576</memory>
  <currentMemory>1048576</currentMemory>
  <vcpu>2</vcpu>
  <os>
    <type arch='i686' machine='pc-0.14'>hvm</type>
    <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</emulator>
    <disk type='file' device='disk'>
      <driver name='qemu' type='qcow2'/>
      <source file='/vms/vm2.qcow2'/>
      <target dev='vda' bus='virtio'/>
      <alias name='virtio-disk0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
    </disk>
    <interface type='bridge'>
      <mac address='52:54:00:5e:98:e4'/>
      <source bridge='br0'/>
      <target dev='vnet0'/>
      <alias name='net0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
    </interface>
    <serial type='pty'>
      <source path='/dev/pts/0'/>
      <target port='0'/>
      <alias name='serial0'/>
    </serial>
    <console type='pty' tty='/dev/pts/0'>
      <source path='/dev/pts/0'/>
      <target type='serial' port='0'/>
      <alias name='serial0'/>
    </console>
    <input type='mouse' bus='ps2'/>
    <graphics type='vnc' port='6900' autoport='no' listen='0.0.0.0'/>
    <video>
      <model type='cirrus' vram='9216' heads='1'/>
      <alias name='video0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
    </video>
    <memballoon model='virtio'>
      <alias name='balloon0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
    </memballoon>
  </devices>
  <seclabel type='dynamic' model='apparmor'>
    <label>libvirt-70affd5d-af95-72c5-2d96-c131f46409b6</label>
    <imagelabel>libvirt-70affd5d-af95-72c5-2d96-c131f46409b6</imagelabel>
  </seclabel>
</domain>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

终止放荡 2024-11-16 01:33:59

这不起作用的原因是因为您正在尝试将磁盘连接到
使用IDE架构运行域。

想象一下你有一个真正的物理服务器,你可以在它运行时打开它吗
并插入 IDE 驱动器?不,该架构不支持它。 KVM/QEMU,
尝试模拟此架构,然后必须呈现您所在的错误
看到:“磁盘总线‘ide’无法热插拔。”

一种解决方案是使用 SCSI 架构连接磁盘。 SCSI 支持热插拔。您将使用的命令是:

virsh Attach-disk --driver file vm2 disk2.qcow2 sdc

唯一的更改是“sdc”而不是“hdc”。这向 KVM/QEMU 暗示您需要 SCSI 而不是 IDE,并且它将附加磁盘。

此外,当域停止时,您无法使用 Attach-disk,因为此功能适用于运行域。

The reason this doesn't work is because you are trying to attach the disk to a
running domain using IDE architecture.

Imagine you have a real physical server, can you open it up while it is running
and plug in an IDE drive? No, the architecture does not support it. KVM/QEMU,
trying to emulate this architecture, must then present the error you are
seeing: "disk bus 'ide' cannot be hotplugged."

One solution is to attach the disk using SCSI archicture. SCSI supports hot plugging. The command you would use would be:

virsh attach-disk --driver file vm2 disk2.qcow2 sdc

The only change is "sdc" instead of "hdc". This hints to KVM/QEMU that you want SCSI instead of IDE, and it will attach the disk.

Also, when the domain is stopped, you can't use attach-disk because this function is meant for running domains.

他夏了夏天 2024-11-16 01:33:59

这个网站的新手,但只是想发表评论,我已成功在 virtd 上上传 iso/热交换映像。
我的命令如下:

virsh attach-disk $srvkvmname /<datastorename>/tsgboot.iso hdb --driver qemu --type cdrom --mode readonly

我知道省略驱动程序类型和 on 会导致上述错误。

newbie to this site but just wanted to comment i have succeeded uploading an iso / hot swap an image on virtd.
my command is as follows:

virsh attach-disk $srvkvmname /<datastorename>/tsgboot.iso hdb --driver qemu --type cdrom --mode readonly

i know that omitting the driver type and on causes the above error.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文