At 2019-12-20 19:23:59, "thomas" <s_ku...@163.com> wrote:

hi, ALL:

my question description as follow:



virsh dumpxml root-vsys_v2  > v2.xml ,  

 in the v2.xml has the following information:

    <disk type='file' device='disk'>
      <driver name='qemu' type='qcow2'/>
      <source file='/home/root-vsys_v2.qcow2'/>
      <backingStore/>
      <target dev='hda' bus='ide'/>  // i want change the 'ide' to 'virtio', 
but fail
      <alias name='ide0-0-0'/>
      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
    </disk>



so i create a new xml name v2-new.xml ,it content is:

    <disk type='file' device='disk'>
      <driver name='qemu' type='qcow2'/>
      <source file='/home/root-vsys_v2.qcow2'/>
      <target dev='vda' bus='virtio'/>
    </disk>



then run:
virsh update-device root-vsys_v2 /root/v2-new.xml  --live

the result is:
[root@NSG ~]# virsh update-device root-vsys_v2 /root/v2-new.xml  --live
error: Failed to update device from /root/v2-new.xml
error: internal error: No device with bus 'virtio' and target 'vda'


i read the source code for libvirt ,the log outprint at funcion:
static int
qemuDomainChangeDiskLive(virDomainObjPtr vm,
                         virDomainDeviceDefPtr dev,
                         virQEMUDriverPtr driver,
                         bool force)
{
    virDomainDiskDefPtr disk = dev->data.disk;
    virDomainDiskDefPtr orig_disk = NULL;
    virDomainDeviceDef oldDev = { .type = dev->type };
    int ret = -1;

    if (!(orig_disk = virDomainDiskFindByBusAndDst(vm->def,
                                                   disk->bus, disk->dst))) {
        virReportError(VIR_ERR_INTERNAL_ERROR,
                       _("No device with bus '%s' and target '%s'"),
                       virDomainDiskBusTypeToString(disk->bus),
                       disk->dst); //the failure log is here, the vm->def has 
disk item :dev = hda, bus=ide ,and disk->bus = virtio disk->dst=vda,
        goto cleanup;
    }

//the disk->bus and disk->dst can't in the vm->def ,so the api 
virDomainDiskFindByBusAndDst failed
    oldDev.data.disk = orig_disk;
    if (virDomainDefCompatibleDevice(vm->def, dev, &oldDev,
                                     VIR_DOMAIN_DEVICE_ACTION_UPDATE,
                                     true) < 0)
        goto cleanup;

    if (!qemuDomainDiskChangeSupported(disk, orig_disk))
        goto cleanup;

    if (!virStorageSourceIsSameLocation(disk->src, orig_disk->src)) {
        /* Disk source can be changed only for removable devices */
        if (disk->device != VIR_DOMAIN_DISK_DEVICE_CDROM &&
            disk->device != VIR_DOMAIN_DISK_DEVICE_FLOPPY) {
            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
                           _("disk source can be changed only in removable "
                             "drives"));
            goto cleanup;
        }

        if (qemuDomainAttachDeviceDiskLive(driver, vm, dev, force) < 0)
            goto cleanup;
    }

    orig_disk->startupPolicy = dev->data.disk->startupPolicy;
    orig_disk->snapshot = dev->data.disk->snapshot;

    ret = 0;
 cleanup:
    return ret;
}



what  reason lead the faiure ? is my v2-new.xml write error ? how to write the 
xml for virsh update-device ?







i refer the link

https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/6/html/virtualization_host_configuration_and_guest_installation_guide/form-virtualization_host_configuration_and_guest_installation_guide-para_virtualized_drivers-using_kvm_para_virtualized_drivers_for_existing_devices



--------------------------
thanks !
thosmas.kuang





 
<domain type='kvm' id='1'>
  <name>root-vsys_v2</name>
  <uuid>6ff7a178-6d0b-4a7f-ac0d-94f3fb9b52e3</uuid>
  <memory unit='KiB'>4194304</memory>
  <currentMemory unit='KiB'>4194304</currentMemory>
  <memoryBacking>
    <hugepages>
      <page size='2048' unit='KiB' nodeset='0'/>
    </hugepages>
  </memoryBacking>
  <vcpu placement='static'>2</vcpu>
  <numatune>
    <memory mode='strict' nodeset='0'/>
  </numatune>
  <resource>
    <partition>/machine</partition>
  </resource>
  <os>
    <type arch='x86_64' machine='pc-i440fx-3.0'>hvm</type>
    <boot dev='hd'/>
  </os>
  <features>
    <acpi/>
    <apic/>
  </features>
  <cpu mode='custom' match='exact' check='full'>
    <model fallback='forbid'>Broadwell</model>
    <vendor>Intel</vendor>
    <topology sockets='1' cores='2' threads='1'/>
    <feature policy='require' name='vme'/>
    <feature policy='require' name='ss'/>
    <feature policy='require' name='f16c'/>
    <feature policy='require' name='rdrand'/>
    <feature policy='require' name='hypervisor'/>
    <feature policy='require' name='arat'/>
    <feature policy='require' name='tsc_adjust'/>
    <feature policy='require' name='xsaveopt'/>
    <feature policy='require' name='abm'/>
    <feature policy='require' name='topoext'/>
    <feature policy='disable' name='erms'/>
    <numa>
      <cell id='0' cpus='0-1' memory='4194304' unit='KiB' memAccess='shared'/>
    </numa>
  </cpu>
  <clock offset='utc'>
    <timer name='rtc' tickpolicy='catchup'/>
    <timer name='pit' tickpolicy='delay'/>
    <timer name='hpet' present='no'/>
  </clock>
  <on_poweroff>destroy</on_poweroff>
  <on_reboot>restart</on_reboot>
  <on_crash>restart</on_crash>
  <pm>
    <suspend-to-mem enabled='no'/>
    <suspend-to-disk enabled='no'/>
  </pm>
  <devices>
    <emulator>/usr/local/bin/qemu-system-x86_64</emulator>
    <disk type='file' device='disk'>
      <driver name='qemu' type='qcow2'/>
      <source file='/home/root-vsys_v2.qcow2'/>
      <backingStore/>
      <target dev='hda' bus='ide'/>
      <alias name='ide0-0-0'/>
      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
    </disk>
    <controller type='usb' index='0' model='piix3-uhci'>
      <alias name='usb'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
    </controller>
    <controller type='pci' index='0' model='pci-root'>
      <alias name='pci.0'/>
    </controller>
    <controller type='ide' index='0'>
      <alias name='ide'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
    </controller>
    <interface type='vhostuser'>
      <mac address='00:04:00:02:01:11'/>
      <source type='unix' path='/secgate/var/run/vh-1-2-0-1-1-1' mode='client'>
        <reconnect enabled='yes' timeout='60'/>
      </source>
      <model type='virtio'/>
      <driver queues='2'/>
      <alias name='net0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
    </interface>
    <interface type='vhostuser'>
      <mac address='00:04:00:02:01:14'/>
      <source type='unix' path='/secgate/var/run/vh-1-2-0-1-1-4' mode='client'>
        <reconnect enabled='yes' timeout='60'/>
      </source>
      <model type='virtio'/>
      <driver queues='2'/>
      <alias name='net1'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
    </interface>
    <interface type='vhostuser'>
      <mac address='00:04:00:02:01:12'/>
      <source type='unix' path='/secgate/var/run/vh-1-2-0-1-1-2' mode='client'>
        <reconnect enabled='yes' timeout='60'/>
      </source>
      <model type='virtio'/>
      <driver queues='2'/>
      <alias name='net2'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
    </interface>
    <interface type='vhostuser'>
      <mac address='00:04:00:02:01:13'/>
      <source type='unix' path='/secgate/var/run/vh-1-2-0-1-1-3' mode='client'>
        <reconnect enabled='yes' timeout='60'/>
      </source>
      <model type='virtio'/>
      <driver queues='2'/>
      <alias name='net3'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/>
    </interface>
    <input type='mouse' bus='ps2'>
      <alias name='input0'/>
    </input>
    <input type='keyboard' bus='ps2'>
      <alias name='input1'/>
    </input>
    <graphics type='vnc' port='5900' autoport='yes' listen='0.0.0.0'>
      <listen type='address' address='0.0.0.0'/>
    </graphics>
    <video>
      <model type='cirrus' vram='16384' heads='1' primary='yes'/>
      <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='0x07' function='0x0'/>
    </memballoon>
  </devices>
  <seclabel type='dynamic' model='dac' relabel='yes'>
    <label>+0:+0</label>
    <imagelabel>+0:+0</imagelabel>
  </seclabel>
</domain>

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Reply via email to