Follow best practices and add a unsigned int flags parameter to these new APIs that have not been in a release yet. Signed-off-by: Jonathon Jongsma <jjongsma@xxxxxxxxxx> --- include/libvirt/libvirt-nodedev.h | 6 ++++-- src/driver-nodedev.h | 6 ++++-- src/libvirt-nodedev.c | 16 ++++++++++------ src/node_device/node_device_driver.c | 10 ++++++++-- src/node_device/node_device_driver.h | 6 ++++-- src/remote/remote_protocol.x | 2 ++ src/remote_protocol-structs | 2 ++ tools/virsh-nodedev.c | 4 ++-- 8 files changed, 36 insertions(+), 16 deletions(-) diff --git a/include/libvirt/libvirt-nodedev.h b/include/libvirt/libvirt-nodedev.h index cf51c3d085..067d914d37 100644 --- a/include/libvirt/libvirt-nodedev.h +++ b/include/libvirt/libvirt-nodedev.h @@ -135,9 +135,11 @@ virNodeDevicePtr virNodeDeviceDefineXML(virConnectPtr conn, const char *xmlDesc, unsigned int flags); -int virNodeDeviceUndefine(virNodeDevicePtr dev); +int virNodeDeviceUndefine(virNodeDevicePtr dev, + unsigned int flags); -int virNodeDeviceCreate(virNodeDevicePtr dev); +int virNodeDeviceCreate(virNodeDevicePtr dev, + unsigned int flags); /** * VIR_NODE_DEVICE_EVENT_CALLBACK: diff --git a/src/driver-nodedev.h b/src/driver-nodedev.h index d2c7f7fe17..75464943a5 100644 --- a/src/driver-nodedev.h +++ b/src/driver-nodedev.h @@ -80,10 +80,12 @@ typedef virNodeDevicePtr unsigned int flags); typedef int -(*virDrvNodeDeviceUndefine)(virNodeDevicePtr dev); +(*virDrvNodeDeviceUndefine)(virNodeDevicePtr dev, + unsigned int flags); typedef int -(*virDrvNodeDeviceCreate)(virNodeDevicePtr dev); +(*virDrvNodeDeviceCreate)(virNodeDevicePtr dev, + unsigned int flags); typedef int (*virDrvConnectNodeDeviceEventRegisterAny)(virConnectPtr conn, diff --git a/src/libvirt-nodedev.c b/src/libvirt-nodedev.c index 477232f630..e416c12534 100644 --- a/src/libvirt-nodedev.c +++ b/src/libvirt-nodedev.c @@ -782,6 +782,7 @@ virNodeDeviceDefineXML(virConnectPtr conn, /** * virNodeDeviceUndefine: * @dev: a device object + * @flags: extra flags; not used yet, so callers should always pass 0 * * Undefine the device object. The virtual device is removed from the host * operating system. This function may require privileged access. @@ -789,9 +790,10 @@ virNodeDeviceDefineXML(virConnectPtr conn, * Returns 0 in case of success and -1 in case of failure. */ int -virNodeDeviceUndefine(virNodeDevicePtr dev) +virNodeDeviceUndefine(virNodeDevicePtr dev, + unsigned int flags) { - VIR_DEBUG("dev=%p", dev); + VIR_DEBUG("dev=%p, flags=0x%x", dev, flags); virResetLastError(); @@ -800,7 +802,7 @@ virNodeDeviceUndefine(virNodeDevicePtr dev) if (dev->conn->nodeDeviceDriver && dev->conn->nodeDeviceDriver->nodeDeviceUndefine) { - int retval = dev->conn->nodeDeviceDriver->nodeDeviceUndefine(dev); + int retval = dev->conn->nodeDeviceDriver->nodeDeviceUndefine(dev, flags); if (retval < 0) goto error; @@ -818,15 +820,17 @@ virNodeDeviceUndefine(virNodeDevicePtr dev) /** * virNodeDeviceCreate: * @dev: a device object + * @flags: extra flags; not used yet, so callers should always pass 0 * * Start a defined node device: * * Returns 0 in case of success and -1 in case of failure. */ int -virNodeDeviceCreate(virNodeDevicePtr dev) +virNodeDeviceCreate(virNodeDevicePtr dev, + unsigned int flags) { - VIR_DEBUG("dev=%p", dev); + VIR_DEBUG("dev=%p, flags=0x%x", dev, flags); virResetLastError(); @@ -835,7 +839,7 @@ virNodeDeviceCreate(virNodeDevicePtr dev) if (dev->conn->nodeDeviceDriver && dev->conn->nodeDeviceDriver->nodeDeviceCreate) { - int retval = dev->conn->nodeDeviceDriver->nodeDeviceCreate(dev); + int retval = dev->conn->nodeDeviceDriver->nodeDeviceCreate(dev, flags); if (retval < 0) goto error; diff --git a/src/node_device/node_device_driver.c b/src/node_device/node_device_driver.c index 951a77f902..c11b8d89ab 100644 --- a/src/node_device/node_device_driver.c +++ b/src/node_device/node_device_driver.c @@ -1341,12 +1341,15 @@ nodeDeviceDefineXML(virConnect *conn, int -nodeDeviceUndefine(virNodeDevice *device) +nodeDeviceUndefine(virNodeDevice *device, + unsigned int flags) { int ret = -1; virNodeDeviceObj *obj = NULL; virNodeDeviceDef *def; + virCheckFlags(0, -1); + if (nodeDeviceWaitInit() < 0) return -1; @@ -1387,12 +1390,15 @@ nodeDeviceUndefine(virNodeDevice *device) int -nodeDeviceCreate(virNodeDevice *device) +nodeDeviceCreate(virNodeDevice *device, + unsigned int flags) { int ret = -1; virNodeDeviceObj *obj = NULL; virNodeDeviceDef *def = NULL; + virCheckFlags(0, -1); + if (!(obj = nodeDeviceObjFindByName(device->name))) return -1; diff --git a/src/node_device/node_device_driver.h b/src/node_device/node_device_driver.h index 4d10be2611..8a935ffed6 100644 --- a/src/node_device/node_device_driver.h +++ b/src/node_device/node_device_driver.h @@ -108,7 +108,8 @@ nodeDeviceDefineXML(virConnect *conn, unsigned int flags); int -nodeDeviceUndefine(virNodeDevice *dev); +nodeDeviceUndefine(virNodeDevice *dev, + unsigned int flags); int nodeConnectNodeDeviceEventRegisterAny(virConnectPtr conn, @@ -165,4 +166,5 @@ nodeDeviceGetMdevctlCreateCommand(const char *uuid, char **errmsg); int -nodeDeviceCreate(virNodeDevice *dev); +nodeDeviceCreate(virNodeDevice *dev, + unsigned int flags); diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x index ecfc708fb7..de69704b68 100644 --- a/src/remote/remote_protocol.x +++ b/src/remote/remote_protocol.x @@ -2156,10 +2156,12 @@ struct remote_node_device_define_xml_ret { struct remote_node_device_undefine_args { remote_nonnull_string name; + unsigned int flags; }; struct remote_node_device_create_args { remote_nonnull_string name; + unsigned int flags; }; diff --git a/src/remote_protocol-structs b/src/remote_protocol-structs index 15bd7ae8f0..6b46328adc 100644 --- a/src/remote_protocol-structs +++ b/src/remote_protocol-structs @@ -1609,9 +1609,11 @@ struct remote_node_device_define_xml_ret { }; struct remote_node_device_undefine_args { remote_nonnull_string name; + u_int flags; }; struct remote_node_device_create_args { remote_nonnull_string name; + u_int flags; }; struct remote_connect_domain_event_register_ret { int cb_registered; diff --git a/tools/virsh-nodedev.c b/tools/virsh-nodedev.c index e13c15b4b0..8b59b1f452 100644 --- a/tools/virsh-nodedev.c +++ b/tools/virsh-nodedev.c @@ -1045,7 +1045,7 @@ cmdNodeDeviceUndefine(vshControl *ctl, const vshCmd *cmd G_GNUC_UNUSED) if (!dev) goto cleanup; - if (virNodeDeviceUndefine(dev) == 0) { + if (virNodeDeviceUndefine(dev, 0) == 0) { vshPrintExtra(ctl, _("Undefined node device '%s'\n"), device_value); } else { vshError(ctl, _("Failed to undefine node device '%s'"), device_value); @@ -1151,7 +1151,7 @@ cmdNodeDeviceStart(vshControl *ctl, const vshCmd *cmd) return false; } - if (virNodeDeviceCreate(device) == 0) { + if (virNodeDeviceCreate(device, 0) == 0) { vshPrintExtra(ctl, _("Device %s started\n"), name); } else { vshError(ctl, _("Failed to start device %s"), name); -- 2.26.3