mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
qemu: support hotplug of vdpa devices
By using the new qemu monitor functions to handle passing and removing file descriptors, we can support hotplug of vdpa devices. Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
This commit is contained in:
committed by
Laine Stump
parent
b8998cc670
commit
b79abf9c3c
@@ -19,11 +19,13 @@
|
||||
#include <config.h>
|
||||
|
||||
#include "qemu/qemu_hotplug.h"
|
||||
#include "qemu/qemu_interface.h"
|
||||
#include "qemu/qemu_process.h"
|
||||
#include "conf/domain_conf.h"
|
||||
#include "virdevmapper.h"
|
||||
#include "virutil.h"
|
||||
#include "virmock.h"
|
||||
#include <fcntl.h>
|
||||
|
||||
static int (*real_virGetDeviceID)(const char *path, int *maj, int *min);
|
||||
static bool (*real_virFileExists)(const char *path);
|
||||
@@ -106,3 +108,10 @@ void
|
||||
qemuProcessKillManagedPRDaemon(virDomainObjPtr vm G_GNUC_UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
int
|
||||
qemuInterfaceVDPAConnect(virDomainNetDefPtr net G_GNUC_UNUSED)
|
||||
{
|
||||
/* need a valid fd or sendmsg won't work. Just open /dev/null */
|
||||
return open("/dev/null", O_RDONLY);
|
||||
}
|
||||
|
||||
@@ -90,6 +90,7 @@ qemuHotplugCreateObjects(virDomainXMLOptionPtr xmlopt,
|
||||
virQEMUCapsSet(priv->qemuCaps, QEMU_CAPS_PR_MANAGER_HELPER);
|
||||
virQEMUCapsSet(priv->qemuCaps, QEMU_CAPS_SCSI_BLOCK);
|
||||
virQEMUCapsSet(priv->qemuCaps, QEMU_CAPS_DEVICE_USB_KBD);
|
||||
virQEMUCapsSet(priv->qemuCaps, QEMU_CAPS_NETDEV_VHOST_VDPA);
|
||||
|
||||
if (qemuTestCapsCacheInsert(driver.qemuCapsCache, priv->qemuCaps) < 0)
|
||||
return -1;
|
||||
@@ -141,6 +142,9 @@ testQemuHotplugAttach(virDomainObjPtr vm,
|
||||
case VIR_DOMAIN_DEVICE_HOSTDEV:
|
||||
ret = qemuDomainAttachHostDevice(&driver, vm, dev->data.hostdev);
|
||||
break;
|
||||
case VIR_DOMAIN_DEVICE_NET:
|
||||
ret = qemuDomainAttachNetDevice(&driver, vm, dev->data.net);
|
||||
break;
|
||||
default:
|
||||
VIR_TEST_VERBOSE("device type '%s' cannot be attached",
|
||||
virDomainDeviceTypeToString(dev->type));
|
||||
@@ -163,6 +167,7 @@ testQemuHotplugDetach(virDomainObjPtr vm,
|
||||
case VIR_DOMAIN_DEVICE_SHMEM:
|
||||
case VIR_DOMAIN_DEVICE_WATCHDOG:
|
||||
case VIR_DOMAIN_DEVICE_HOSTDEV:
|
||||
case VIR_DOMAIN_DEVICE_NET:
|
||||
ret = qemuDomainDetachDeviceLive(vm, dev, &driver, async);
|
||||
break;
|
||||
default:
|
||||
@@ -824,6 +829,17 @@ mymain(void)
|
||||
DO_TEST_DETACH("pseries-base-live", "hostdev-pci", false, false,
|
||||
"device_del", QMP_DEVICE_DELETED("hostdev0") QMP_OK);
|
||||
|
||||
DO_TEST_ATTACH("base-live", "interface-vdpa", false, true,
|
||||
"add-fd", "{ \"return\": { \"fdset-id\": 1, \"fd\": 95 }}",
|
||||
"netdev_add", QMP_OK, "device_add", QMP_OK);
|
||||
DO_TEST_DETACH("base-live", "interface-vdpa", false, false,
|
||||
"device_del", QMP_DEVICE_DELETED("net0") QMP_OK,
|
||||
"netdev_del", QMP_OK,
|
||||
"query-fdsets",
|
||||
"{ \"return\": [{\"fds\": [{\"fd\": 95, \"opaque\": \"/dev/vhost-vdpa-0\"}], \"fdset-id\": 1}]}",
|
||||
"remove-fd", QMP_OK
|
||||
);
|
||||
|
||||
DO_TEST_ATTACH("base-live", "watchdog", false, true,
|
||||
"watchdog-set-action", QMP_OK,
|
||||
"device_add", QMP_OK);
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
<interface type='vdpa'>
|
||||
<mac address='52:54:00:39:5f:04'/>
|
||||
<source dev='/dev/vhost-vdpa-0'/>
|
||||
</interface>
|
||||
@@ -0,0 +1,57 @@
|
||||
<domain type='kvm' id='7'>
|
||||
<name>hotplug</name>
|
||||
<uuid>d091ea82-29e6-2e34-3005-f02617b36e87</uuid>
|
||||
<memory unit='KiB'>4194304</memory>
|
||||
<currentMemory unit='KiB'>4194304</currentMemory>
|
||||
<vcpu placement='static'>4</vcpu>
|
||||
<os>
|
||||
<type arch='x86_64' machine='pc'>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/qemu-system-x86_64</emulator>
|
||||
<controller type='usb' index='0'>
|
||||
<alias name='usb'/>
|
||||
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
|
||||
</controller>
|
||||
<controller type='ide' index='0'>
|
||||
<alias name='ide'/>
|
||||
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
|
||||
</controller>
|
||||
<controller type='scsi' index='0' model='virtio-scsi'>
|
||||
<alias name='scsi0'/>
|
||||
<address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
|
||||
</controller>
|
||||
<controller type='pci' index='0' model='pci-root'>
|
||||
<alias name='pci'/>
|
||||
</controller>
|
||||
<controller type='virtio-serial' index='0'>
|
||||
<alias name='virtio-serial0'/>
|
||||
<address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
|
||||
</controller>
|
||||
<interface type='vdpa'>
|
||||
<mac address='52:54:00:39:5f:04'/>
|
||||
<source dev='/dev/vhost-vdpa-0'/>
|
||||
<model type='virtio'/>
|
||||
<alias name='net0'/>
|
||||
<address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
|
||||
</interface>
|
||||
<input type='mouse' bus='ps2'>
|
||||
<alias name='input0'/>
|
||||
</input>
|
||||
<input type='keyboard' bus='ps2'>
|
||||
<alias name='input1'/>
|
||||
</input>
|
||||
<memballoon model='none'/>
|
||||
</devices>
|
||||
<seclabel type='none' model='none'/>
|
||||
</domain>
|
||||
Reference in New Issue
Block a user