Re: [PATCH v3 1/2] qemu: Add support for hot unplugging redirdev device which can use the detach-device --live

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On 01/05/2018 05:40 AM, Ján Tomko wrote:
> On Fri, Dec 22, 2017 at 04:04:03PM +0800, Chen Hanxiao wrote:
>> From: Chen Hanxiao <chenhanxiao@xxxxxxxxx>
>>
>> We lacked of hot unplugging redirdev device.
>> This patch add support for it.
>> We could use detach-device --live now.
>>
>> Signed-off-by: Chen Hanxiao <chenhanxiao@xxxxxxxxx>
>> ---
>> v3:
>>  use helper qemuDomainDelChardevTLSObjects
>>  address John's comments
>>
>> v2:
>>  rebase on master
>>
>> src/qemu/qemu_driver.c  |  4 ++-
>> src/qemu/qemu_hotplug.c | 91
>> +++++++++++++++++++++++++++++++++++++++++++++++++
>> src/qemu/qemu_hotplug.h |  4 +++
>> 3 files changed, 98 insertions(+), 1 deletion(-)
>>

[...]

>> +int
>> +qemuDomainDetachRedirdevDevice(virQEMUDriverPtr driver,
>> +                               virDomainObjPtr vm,
>> +                               virDomainRedirdevDefPtr dev)
>> +{
>> +    int ret = -1;
>> +    qemuDomainObjPrivatePtr priv = vm->privateData;
>> +    virDomainRedirdevDefPtr tmpRedirdevDef;
>> +    ssize_t idx;
>> +
>> +    if ((idx = virDomainRedirdevDefFind(vm->def, dev)) < 0) {
>> +        virReportError(VIR_ERR_OPERATION_INVALID, "%s",
>> +                       _("no matching redirdev was not found"));
>> +        return -1;
>> +    }
>> +
>> +    tmpRedirdevDef = vm->def->redirdevs[idx];
>> +
>> +    if (!tmpRedirdevDef->info.alias) {
>> +        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
>> +                       _("alias not set for redirdev device"));
>> +        return -1;
>> +    }
>> +
>> +    qemuDomainMarkDeviceForRemoval(vm, &tmpRedirdevDef->info);
>> +
>> +    qemuDomainObjEnterMonitor(driver, vm);
>> +    if (qemuMonitorDelDevice(priv->mon, tmpRedirdevDef->info.alias) <
>> 0) {
>> +        ignore_value(qemuDomainObjExitMonitor(driver, vm));
>> +        goto cleanup;
>> +    }
>> +    if (qemuDomainObjExitMonitor(driver, vm) < 0)
>> +        goto cleanup;
>> +
>> +    if ((ret = qemuDomainWaitForDeviceRemoval(vm)) == 1)
>> +        ret = qemuDomainRemoveRedirdevDevice(driver, vm,
>> tmpRedirdevDef);
> 
> If qemuDomainWaitForDeviceRemoval returns 0 (QEMU supports
> DEVICE_DEL_EVENT and did not unplug the device in 5 seconds),
> then libvirtd should remove the device asynchronnously, when the device
> deletion event arrives.
> 
> qemuDomainRemoveRedirdevDevice needs to be also called from
> qemuDomainRemoveDevice for that to happen.
> 
> Jan
> 

oh yeah - right, adding :

+    case VIR_DOMAIN_DEVICE_REDIRDEV:
+        ret = qemuDomainRemoveRedirdevDevice(driver, vm,
dev->data.redirdev);
+        break;
+

to qemuDomainRemoveDevice

Tks -

John

>> +
>> + cleanup:
>> +    qemuDomainResetDeviceRemoval(vm);
>> +    return ret;
>> +}
>> +
>> +
>> int
>> qemuDomainDetachNetDevice(virQEMUDriverPtr driver,
>>                           virDomainObjPtr vm,
>> diff --git a/src/qemu/qemu_hotplug.h b/src/qemu/qemu_hotplug.h
>> index 3e0d618e0..9a0c057f1 100644
>> --- a/src/qemu/qemu_hotplug.h
>> +++ b/src/qemu/qemu_hotplug.h
>> @@ -126,6 +126,10 @@ int qemuDomainDetachWatchdog(virQEMUDriverPtr
>> driver,
>>                              virDomainObjPtr vm,
>>                              virDomainWatchdogDefPtr watchdog);
>>
>> +int qemuDomainDetachRedirdevDevice(virQEMUDriverPtr driver,
>> +                                   virDomainObjPtr vm,
>> +                                   virDomainRedirdevDefPtr dev);
>> +
>> int qemuDomainAttachInputDevice(virQEMUDriverPtr driver,
>>                                 virDomainObjPtr vm,
>>                                 virDomainInputDefPtr input);
>> -- 
>> 2.14.3
>>
>> -- 
>> libvir-list mailing list
>> libvir-list@xxxxxxxxxx
>> https://www.redhat.com/mailman/listinfo/libvir-list
> 
> 
> --
> libvir-list mailing list
> libvir-list@xxxxxxxxxx
> https://www.redhat.com/mailman/listinfo/libvir-list
> 

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




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]
  Powered by Linux