【问题标题】:How to detach a disk from KVM correctly如何正确从 KVM 分离磁盘
【发布时间】:2013-04-07 14:03:37
【问题描述】:

当我尝试在 KVM 中分离驱动器时,我收到以下错误:

virsh 分离磁盘 vps_99 vde

错误:操作失败:磁盘 vde 无法分离 - 设备没有 PCI 地址

我试过google,但找不到其他人有同样的问题??

这是我的 VPS 的 XML 转储:

(root@h2)-(/home/cloud)# virsh dumpxml vps_99
<domain type='kvm' id='218'>
  <name>vps_99</name>
  <uuid>42db1de2-f0d4-1030-ac57-0050560018a2</uuid>
  <memory>524288</memory>
  <currentMemory>524288</currentMemory>
  <vcpu>1</vcpu>
  <os>
    <type arch='x86_64' machine='pc-0.12'>hvm</type>
    <boot dev='hd'/>
  </os>
  <features>
    <acpi/>
    <apic/>
    <pae/>
  </features>
  <clock offset='utc'/>
  <on_poweroff>restart</on_poweroff>
  <on_reboot>restart</on_reboot>
  <on_crash>restart</on_crash>
  <devices>
    <emulator>/usr/bin/kvm</emulator>
    <disk type='block' device='disk'>
      <driver name='qemu' type='raw'/>
      <source dev='/dev/nbd1'/>
      <target dev='vda' bus='virtio'/>
    </disk>
    <disk type='block' device='disk'>
      <driver name='qemu' type='raw'/>
      <source dev='/dev/nbd2'/>
      <target dev='vdb' bus='virtio'/>
    </disk>
    <disk type='block' device='disk'>
      <driver name='qemu' type='raw'/>
      <source dev='/dev/nbd3'/>
      <target dev='vde' bus='virtio'/>
    </disk>
    <interface type='bridge'>
      <mac address='00:50:56:00:1b:24'/>
      <source bridge='br0'/>
      <target dev='vnet3'/>
      <model type='virtio'/>
    </interface>
    <input type='mouse' bus='ps2'/>
    <graphics type='vnc' port='5903' autoport='yes' keymap='en-us'/>
    <video>
      <model type='cirrus' vram='9216' heads='1'/>
    </video>
  </devices>
  <seclabel type='dynamic' model='apparmor'>
    <label>libvirt-42db1de2-f0d4-1030-ac57-0050560018a2</label>
    <imagelabel>libvirt-42db1de2-f0d4-1030-ac57-0050560018a2</imagelabel>
  </seclabel>
</domain>

另一个疯狂的事情是,我指定为“vde”的驱动器以“vdc”的形式连接到虚拟服务器,就好像它完全忽略了我的“vde”规范一样。

如果有人能告诉我如何确保驱动器连接到我指定的设备,我会很感激。 Amazon Web Services 似乎可以做到,那我为什么不呢:)

更新:虚拟机启动后,我似乎可以毫无问题地添加和删除新磁盘。分离在用于创建虚拟服务器的原始 XML 中定义的磁盘似乎只是问题。但问题依然存在,如何分离定义虚拟服务器时定义的磁盘?

更新 2:我还尝试为每个磁盘添加一个 &lt;address&gt; 条目,以确保每个磁盘都连接到预定义的插槽,即 &lt;address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/&gt; 但仍然无法分离磁盘,并且“virsh dumpxml vps_99”实际上表明我的条目已被完全删除/忽略。

更新 3:我还尝试将磁盘定义放在临时 XML 文件中并运行:virsh detach-device vps_99 disk.xml 还是一样的错误: 错误:无法从 disk.xml 分离设备 错误:操作失败:磁盘 vdi 无法分离 - 设备没有 PCI 地址

【问题讨论】:

    标签: virtualization kvm libvirt


    【解决方案1】:

    您可以使用libvirt 完成此操作。您必须将设备的 xml 描述为xlmDec

    例如:

    virDom.detachDevice(xmldesc)
    

    【讨论】:

    • 这不适用于 CDROM 驱动器并导致error: Operation not supported: disk device type 'cdrom' cannot be detached
    猜你喜欢
    • 2016-11-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-02-23
    • 2021-09-30
    • 2013-05-18
    • 2010-12-01
    • 1970-01-01
    相关资源
    最近更新 更多