test: Sync GetXML INACTIVE behavior with live driver

- Error if INACTIVE requested for transient object
- Force dumping INACTIVE XML when object is inactive

Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
This commit is contained in:
Cole Robinson 2024-04-17 11:07:14 -04:00
parent 2b487f564e
commit 8ee34bb551

View File

@ -7514,15 +7514,30 @@ testNodeDeviceGetXMLDesc(virNodeDevicePtr dev,
{
testDriver *driver = dev->conn->privateData;
virNodeDeviceObj *obj;
virNodeDeviceDef *def;
char *ret = NULL;
virCheckFlags(VIR_NODE_DEVICE_XML_INACTIVE, NULL);
if (!(obj = testNodeDeviceObjFindByName(driver, dev->name)))
return NULL;
def = virNodeDeviceObjGetDef(obj);
ret = virNodeDeviceDefFormat(virNodeDeviceObjGetDef(obj), flags);
if (flags & VIR_NODE_DEVICE_XML_INACTIVE) {
if (!virNodeDeviceObjIsPersistent(obj)) {
virReportError(VIR_ERR_OPERATION_INVALID,
_("node device '%1$s' is not persistent"),
def->name);
goto cleanup;
}
} else {
if (!virNodeDeviceObjIsActive(obj))
flags |= VIR_NODE_DEVICE_XML_INACTIVE;
}
ret = virNodeDeviceDefFormat(def, flags);
cleanup:
virNodeDeviceObjEndAPI(&obj);
return ret;
}