On Mon, Oct 30, 2023 at 03:16:49PM +0000, Thanos Makatos wrote: > Signed-off-by: Thanos Makatos <thanos.makatos@xxxxxxxxxxx> > --- > 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 :|