首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >virsh命令的问题

virsh命令的问题
EN

Stack Overflow用户
提问于 2011-05-21 22:47:52
回答 2查看 9.2K关注 0票数 1

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

代码语言:javascript
复制
virsh attach-disk --driver file vm2 disk2.qcow2 hdc

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

代码语言:javascript
复制
error: this function is not supported by the hypervisor: disk bus 'ide' cannot be hotplugged.

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

代码语言:javascript
复制
error: Requested operation is not valid: cannot attach device on inactive domain

我不确定hdc参数。我也尝试过对xml文件使用attach-device函数,如下所示:

代码语言:javascript
复制
<disk type="file" device="disk">
    <driver name="file"/>
    <source file="/gfs1/disk2.qcow2"/>
    <target dev="hdc"/>
</disk>

但这也表明:

代码语言:javascript
复制
error: Failed to attach device from /gfs1/disk2tovm2.xml
error: this function is not supported by the hypervisor: disk bus 'ide' cannot be hotplugged.

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

虚拟机的完整配置文件

代码语言:javascript
复制
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>
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2011-10-06 19:23:18

这不起作用的原因是因为您正在尝试使用IDE体系结构将磁盘附加到正在运行的域。

假设你有一台真实的物理服务器,你能在它运行时打开它并插入IDE驱动器吗?不,架构不支持它。KVM/QEMU试图模拟这种体系结构,然后必须显示您看到的错误:“磁盘总线'ide‘无法热插拔”。

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

virsh attach-disk --driver文件vm2 disk2.qco2sdc

唯一的变化是"sdc“而不是"hdc”。这提示KVM/QEMU您需要SCSI而不是IDE,它将连接磁盘。

此外,当域停止时,您不能使用attach-disk,因为此函数适用于正在运行的域。

票数 5
EN

Stack Overflow用户

发布于 2013-12-18 19:40:53

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

代码语言:javascript
复制
virsh attach-disk $srvkvmname /<datastorename>/tsgboot.iso hdb --driver qemu --type cdrom --mode readonly

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

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/6082474

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档