【问题标题】:Problem with virsh commandsvirsh 命令的问题
【发布时间】:2011-05-21 14:47:51
【问题描述】:

我一直在尝试使用 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 参数。我也尝试将附加设备功能与 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>

【问题讨论】:

  • 你能发布你的虚拟机其余部分的配置吗?你在用 Virtio 吗?另外,我认为您的 cdrom 可能配置了 hdc。
  • 我在问题本身中添加了完整的vm配置。

标签: ide disk kvm hotplugging


【解决方案1】:

这不起作用的原因是因为您试图将磁盘附加到 使用 IDE 架构运行域。

假设你有一个真正的物理服务器,你能在它运行的时候打开它吗 并插入IDE驱动器?不,架构不支持它。 KVM/QEMU, 试图模仿这种架构,然后必须呈现你所遇到的错误 看到:“磁盘总线 'ide' 不能被热插拔。”

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

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

唯一的变化是“sdc”而不是“hdc”。这向 KVM/QEMU 提示您需要 SCSI 而不是 IDE,它会附加磁盘。

此外,当域停止时,您不能使用 attach-disk,因为此功能是用于运行域的。

【讨论】:

    【解决方案2】:

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

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

    我知道省略驱动程序类型并打开会导致上述错误。

    【讨论】:

    • 它看起来有所不同,因为您将其附加为 cdrom 而不是硬盘。如果我错了,请纠正我。
    • 是的,我正在附加一个 cdrom,但如果想要一个 HD,它似乎使用相同的方式,只更改类型。我还没有测试过,所以如果有人可以确认它会很棒。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-03-14
    • 2020-07-23
    • 2013-12-17
    • 2021-04-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多