src/test/test_driver.c | 59 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+)
Signed-off-by: Thanos Makatos <thanos.makatos@nutanix.com>
---
src/test/test_driver.c | 59 ++++++++++++++++++++++++++++++++++++++++++
1 file changed, 59 insertions(+)
diff --git a/src/test/test_driver.c b/src/test/test_driver.c
index e87d7cfd44..80ef1b3cbb 100644
--- a/src/test/test_driver.c
+++ b/src/test/test_driver.c
@@ -10035,6 +10035,62 @@ testConnectGetDomainCapabilities(virConnectPtr conn G_GNUC_UNUSED,
return virDomainCapsFormat(domCaps);
}
+static int
+testVirDomainAttachDeviceFlags(virDomainPtr domain,
+ const char *xml,
+ unsigned int flags G_GNUC_UNUSED) {
+
+ int ret = -1;
+ virDomainObj *vm;
+ testDriver *driver;
+ virDomainDeviceDef *devConf;
+
+ if (!(vm = testDomObjFromDomain(domain)))
+ return -1;
+
+ driver = domain->conn->privateData;
+
+ if (!(devConf = virDomainDeviceDefParse(xml, vm->def, driver->xmlopt,
+ NULL, 0)))
+ goto out;
+
+ VIR_APPEND_ELEMENT(vm->def->hostdevs, vm->def->nhostdevs,
+ devConf->data.hostdev);
+ virDomainDeviceDefFree(devConf);
+ ret = 0;
+out:
+ virDomainObjEndAPI(&vm);
+ return ret;
+}
+
+static int
+testVirDomainAttachDevice(virDomainPtr domain, const char *xml)
+{
+ return testVirDomainAttachDeviceFlags(domain, xml, 0);
+}
+
+static int
+testVirDomainDetachDeviceAlias(virDomainPtr domain,
+ const char *alias,
+ unsigned int flags G_GNUC_UNUSED)
+{
+ virDomainObj *vm;
+ int size_t;
+ bool found = false;
+
+ if (!(vm = testDomObjFromDomain(domain)))
+ return -1;
+
+ for (i = 0; i < vm->def->nhostdevs && !found; i++) {
+ if (!strcmp(vm->def->hostdevs[i]->info->alias, alias)) {
+ virDomainHostdevDefFree(vm->def->hostdevs[i]);
+ VIR_DELETE_ELEMENT(vm->def->hostdevs, i, vm->def->nhostdevs);
+ found = true;
+ }
+ }
+ virDomainObjEndAPI(&vm);
+ return found ? 0 : -1;
+}
/*
* Test driver
@@ -10058,6 +10114,9 @@ static virHypervisorDriver testHypervisorDriver = {
.connectListDomains = testConnectListDomains, /* 0.1.1 */
.connectNumOfDomains = testConnectNumOfDomains, /* 0.1.1 */
.connectListAllDomains = testConnectListAllDomains, /* 0.9.13 */
+ .domainAttachDevice = testVirDomainAttachDevice, /* 9.9.0 */
+ .domainAttachDeviceFlags = testVirDomainAttachDeviceFlags, /* 9.9.0 */
+ .domainDetachDeviceAlias = testVirDomainDetachDeviceAlias, /* 9.9.0 */
.domainCreateXML = testDomainCreateXML, /* 0.1.4 */
.domainCreateXMLWithFiles = testDomainCreateXMLWithFiles, /* 5.7.0 */
.domainLookupByID = testDomainLookupByID, /* 0.1.1 */
--
2.27.0
On Mon, Oct 30, 2023 at 03:16:49PM +0000, Thanos Makatos wrote: > Signed-off-by: Thanos Makatos <thanos.makatos@nutanix.com> > --- > src/test/test_driver.c | 59 ++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 59 insertions(+) > > diff --git a/src/test/test_driver.c b/src/test/test_driver.c > index e87d7cfd44..80ef1b3cbb 100644 > --- a/src/test/test_driver.c > +++ b/src/test/test_driver.c > @@ -10035,6 +10035,62 @@ testConnectGetDomainCapabilities(virConnectPtr conn G_GNUC_UNUSED, > return virDomainCapsFormat(domCaps); > } > > +static int > +testVirDomainAttachDeviceFlags(virDomainPtr domain, > + const char *xml, > + unsigned int flags G_GNUC_UNUSED) { > + > + int ret = -1; > + virDomainObj *vm; > + testDriver *driver; > + virDomainDeviceDef *devConf; > + > + if (!(vm = testDomObjFromDomain(domain))) > + return -1; > + > + driver = domain->conn->privateData; > + > + if (!(devConf = virDomainDeviceDefParse(xml, vm->def, driver->xmlopt, > + NULL, 0))) > + goto out; > + > + VIR_APPEND_ELEMENT(vm->def->hostdevs, vm->def->nhostdevs, > + devConf->data.hostdev); > + virDomainDeviceDefFree(devConf); > + ret = 0; > +out: > + virDomainObjEndAPI(&vm); > + return ret; > +} > + > +static int > +testVirDomainAttachDevice(virDomainPtr domain, const char *xml) > +{ > + return testVirDomainAttachDeviceFlags(domain, xml, 0); > +} > + > +static int > +testVirDomainDetachDeviceAlias(virDomainPtr domain, > + const char *alias, > + unsigned int flags G_GNUC_UNUSED) > +{ > + virDomainObj *vm; > + int size_t; ^^^^^ this doesn't look right and won't even compile i expect > + bool found = false; > + > + if (!(vm = testDomObjFromDomain(domain))) > + return -1; > + > + for (i = 0; i < vm->def->nhostdevs && !found; i++) { > + if (!strcmp(vm->def->hostdevs[i]->info->alias, alias)) { > + virDomainHostdevDefFree(vm->def->hostdevs[i]); > + VIR_DELETE_ELEMENT(vm->def->hostdevs, i, vm->def->nhostdevs); > + found = true; > + } > + } > + virDomainObjEndAPI(&vm); > + return found ? 0 : -1; > +} > > /* > * Test driver > @@ -10058,6 +10114,9 @@ static virHypervisorDriver testHypervisorDriver = { > .connectListDomains = testConnectListDomains, /* 0.1.1 */ > .connectNumOfDomains = testConnectNumOfDomains, /* 0.1.1 */ > .connectListAllDomains = testConnectListAllDomains, /* 0.9.13 */ > + .domainAttachDevice = testVirDomainAttachDevice, /* 9.9.0 */ > + .domainAttachDeviceFlags = testVirDomainAttachDeviceFlags, /* 9.9.0 */ > + .domainDetachDeviceAlias = testVirDomainDetachDeviceAlias, /* 9.9.0 */ > .domainCreateXML = testDomainCreateXML, /* 0.1.4 */ > .domainCreateXMLWithFiles = testDomainCreateXMLWithFiles, /* 5.7.0 */ > .domainLookupByID = testDomainLookupByID, /* 0.1.1 */ > -- > 2.27.0 > With regards, Daniel -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
> -----Original Message----- > From: Daniel P. Berrangé <berrange@redhat.com> > Sent: Monday, October 30, 2023 3:55 PM > To: Thanos Makatos <thanos.makatos@nutanix.com> > Cc: devel@lists.libvirt.org > Subject: Re: [PATCH V2] support for hotplug/hotunplug in test hypervisor > > On Mon, Oct 30, 2023 at 03:16:49PM +0000, Thanos Makatos wrote: > > Signed-off-by: Thanos Makatos <thanos.makatos@nutanix.com> > > --- > > src/test/test_driver.c | 59 > ++++++++++++++++++++++++++++++++++++++++++ > > 1 file changed, 59 insertions(+) > > > > diff --git a/src/test/test_driver.c b/src/test/test_driver.c > > index e87d7cfd44..80ef1b3cbb 100644 > > --- a/src/test/test_driver.c > > +++ b/src/test/test_driver.c > > @@ -10035,6 +10035,62 @@ > testConnectGetDomainCapabilities(virConnectPtr conn G_GNUC_UNUSED, > > return virDomainCapsFormat(domCaps); > > } > > > > +static int > > +testVirDomainAttachDeviceFlags(virDomainPtr domain, > > + const char *xml, > > + unsigned int flags G_GNUC_UNUSED) { > > + > > + int ret = -1; > > + virDomainObj *vm; > > + testDriver *driver; > > + virDomainDeviceDef *devConf; > > + > > + if (!(vm = testDomObjFromDomain(domain))) > > + return -1; > > + > > + driver = domain->conn->privateData; > > + > > + if (!(devConf = virDomainDeviceDefParse(xml, vm->def, driver->xmlopt, > > + NULL, 0))) > > + goto out; > > + > > + VIR_APPEND_ELEMENT(vm->def->hostdevs, vm->def->nhostdevs, > > + devConf->data.hostdev); > > + virDomainDeviceDefFree(devConf); > > + ret = 0; > > +out: > > + virDomainObjEndAPI(&vm); > > + return ret; > > +} > > + > > +static int > > +testVirDomainAttachDevice(virDomainPtr domain, const char *xml) > > +{ > > + return testVirDomainAttachDeviceFlags(domain, xml, 0); > > +} > > + > > +static int > > +testVirDomainDetachDeviceAlias(virDomainPtr domain, > > + const char *alias, > > + unsigned int flags G_GNUC_UNUSED) > > +{ > > + virDomainObj *vm; > > + int size_t; > > ^^^^^ this doesn't look right and won't even compile i expect Sorry! > > > + bool found = false; > > + > > + if (!(vm = testDomObjFromDomain(domain))) > > + return -1; > > + > > + for (i = 0; i < vm->def->nhostdevs && !found; i++) { > > + if (!strcmp(vm->def->hostdevs[i]->info->alias, alias)) { > > + virDomainHostdevDefFree(vm->def->hostdevs[i]); > > + VIR_DELETE_ELEMENT(vm->def->hostdevs, i, vm->def->nhostdevs); > > + found = true; > > + } > > + } > > + virDomainObjEndAPI(&vm); > > + return found ? 0 : -1; > > +} > > > > /* > > * Test driver > > @@ -10058,6 +10114,9 @@ static virHypervisorDriver testHypervisorDriver = > { > > .connectListDomains = testConnectListDomains, /* 0.1.1 */ > > .connectNumOfDomains = testConnectNumOfDomains, /* 0.1.1 */ > > .connectListAllDomains = testConnectListAllDomains, /* 0.9.13 */ > > + .domainAttachDevice = testVirDomainAttachDevice, /* 9.9.0 */ > > + .domainAttachDeviceFlags = testVirDomainAttachDeviceFlags, /* 9.9.0 */ > > + .domainDetachDeviceAlias = testVirDomainDetachDeviceAlias, /* 9.9.0 */ > > .domainCreateXML = testDomainCreateXML, /* 0.1.4 */ > > .domainCreateXMLWithFiles = testDomainCreateXMLWithFiles, /* 5.7.0 */ > > .domainLookupByID = testDomainLookupByID, /* 0.1.1 */ > > -- > > 2.27.0 > > > > With regards, > Daniel > -- > |: https://urldefense.proofpoint.com/v2/url?u=https- > 3A__berrange.com&d=DwIBaQ&c=s883GpUCOChKOHiocYtGcg&r=XTpYsh5Ps2zJ > vtw6ogtti46atk736SI4vgsJiUKIyDE&m=DpeOKh65K_mz6mh42NlATYaEk3ZsMQx > 5Bno7s_D1qKjMUJkMdZromAXFGUfBlvDe&s=vvMNvtjmjnCsNFz4K2joLdIpICFXk > T-Bq7Cjvd3F6QI&e= -o- > https://urldefense.proofpoint.com/v2/url?u=https- > 3A__www.flickr.com_photos_dberrange&d=DwIBaQ&c=s883GpUCOChKOHiocYt > Gcg&r=XTpYsh5Ps2zJvtw6ogtti46atk736SI4vgsJiUKIyDE&m=DpeOKh65K_mz6m > h42NlATYaEk3ZsMQx5Bno7s_D1qKjMUJkMdZromAXFGUfBlvDe&s=zxZbPx43V6 > CAvORu7PztYWUGxePHdAvhlBzJ2lTIfjc&e= :| > |: https://urldefense.proofpoint.com/v2/url?u=https- > 3A__libvirt.org&d=DwIBaQ&c=s883GpUCOChKOHiocYtGcg&r=XTpYsh5Ps2zJvtw > 6ogtti46atk736SI4vgsJiUKIyDE&m=DpeOKh65K_mz6mh42NlATYaEk3ZsMQx5Bn > o7s_D1qKjMUJkMdZromAXFGUfBlvDe&s=3K8SPf9T6_NuCbTsOJM1Lvuqvfak6ps > ymt4qtDpL5p4&e= -o- > https://urldefense.proofpoint.com/v2/url?u=https- > 3A__fstop138.berrange.com&d=DwIBaQ&c=s883GpUCOChKOHiocYtGcg&r=XTp > Ysh5Ps2zJvtw6ogtti46atk736SI4vgsJiUKIyDE&m=DpeOKh65K_mz6mh42NlATYaE > k3ZsMQx5Bno7s_D1qKjMUJkMdZromAXFGUfBlvDe&s=guxV0DRbfgeWkb6LXN > UzGGt721-6QPIh4MOSRxOnOV0&e= :| > |: https://urldefense.proofpoint.com/v2/url?u=https-3A__entangle- > 2Dphoto.org&d=DwIBaQ&c=s883GpUCOChKOHiocYtGcg&r=XTpYsh5Ps2zJvtw6o > gtti46atk736SI4vgsJiUKIyDE&m=DpeOKh65K_mz6mh42NlATYaEk3ZsMQx5Bno7 > s_D1qKjMUJkMdZromAXFGUfBlvDe&s=KrDsvg9IC9Xf9EmtNrV- > YqGHD5pOg5W_oPl0bEMeNRw&e= -o- > https://urldefense.proofpoint.com/v2/url?u=https- > 3A__www.instagram.com_dberrange&d=DwIBaQ&c=s883GpUCOChKOHiocYtGc > g&r=XTpYsh5Ps2zJvtw6ogtti46atk736SI4vgsJiUKIyDE&m=DpeOKh65K_mz6mh4 > 2NlATYaEk3ZsMQx5Bno7s_D1qKjMUJkMdZromAXFGUfBlvDe&s=X5Lyjdgd4bC8 > PrbvemrlncYITBP6JFhNtgP2ZiqTVd0&e= :|
© 2016 - 2024 Red Hat, Inc.