int virNodeDeviceIsActive(virNodeDevicePtr dev);
+/**
+ * virNodeDeviceUpdateFlags:
+ *
+ * Flags to control options for virNodeDeviceUpdate()
+ *
+ * Since: 10.1.0
+ */
+typedef enum {
+ VIR_NODE_DEVICE_UPDATE_AFFECT_CURRENT = 0, /* affect live if node device is active,
+ config if it's not active (Since: 10.1.0) */
+ VIR_NODE_DEVICE_UPDATE_AFFECT_LIVE = 1 << 0, /* affect live state of node device only (Since: 10.1.0) */
+ VIR_NODE_DEVICE_UPDATE_AFFECT_CONFIG = 1 << 1, /* affect persistent config only (Since: 10.1.0) */
+} virNodeDeviceUpdateFlags;
+
+int virNodeDeviceUpdate(virNodeDevicePtr dev,
+ const char *xmlDesc,
+ unsigned int flags);
+
/**
* VIR_NODE_DEVICE_EVENT_CALLBACK:
*
"getattr", "read", "write",
"start", "stop",
"detach", "delete",
+ "save",
);
VIR_ENUM_IMPL(virAccessPermNWFilter,
*/
VIR_ACCESS_PERM_NODE_DEVICE_DELETE,
+ /**
+ * @desc: Save node device
+ * @message: Saving node device driver requires authorization
+ */
+ VIR_ACCESS_PERM_NODE_DEVICE_SAVE,
+
VIR_ACCESS_PERM_NODE_DEVICE_LAST
} virAccessPermNodeDevice;
virNodeDeviceObjListFindHelper,
&data);
}
+
+
+/**
+ * virNodeDeviceObjUpdateModificationImpact:
+ * @obj: Pointer to node device object
+ * @flags: flags to update the modification impact on
+ *
+ * Resolves virNodeDeviceUpdateFlags flags in @flags so that they correctly
+ * apply to the actual state of @obj. @flags may be modified after call to this
+ * function.
+ *
+ * Returns 0 on success if @flags point to a valid combination for @obj or -1
+ * on error.
+ */
+int
+virNodeDeviceObjUpdateModificationImpact(virNodeDeviceObj *obj,
+ unsigned int *flags)
+{
+ bool isActive = virNodeDeviceObjIsActive(obj);
+
+ if ((*flags & (VIR_NODE_DEVICE_UPDATE_AFFECT_LIVE | VIR_NODE_DEVICE_UPDATE_AFFECT_CONFIG)) ==
+ VIR_NODE_DEVICE_UPDATE_AFFECT_CURRENT) {
+ if (isActive)
+ *flags |= VIR_NODE_DEVICE_UPDATE_AFFECT_LIVE;
+ else
+ *flags |= VIR_NODE_DEVICE_UPDATE_AFFECT_CONFIG;
+ }
+
+ if (!isActive && (*flags & VIR_NODE_DEVICE_UPDATE_AFFECT_LIVE)) {
+ virReportError(VIR_ERR_OPERATION_INVALID, "%s",
+ _("node device is not active"));
+ return -1;
+ }
+
+ if (!virNodeDeviceObjIsPersistent(obj) && (*flags & VIR_NODE_DEVICE_UPDATE_AFFECT_CONFIG)) {
+ virReportError(VIR_ERR_OPERATION_INVALID, "%s",
+ _("transient node devices do not have any persistent config"));
+ return -1;
+ }
+
+ return 0;
+}
virNodeDeviceObjListFind(virNodeDeviceObjList *devs,
virNodeDeviceObjListPredicate callback,
void *opaque);
+
+int virNodeDeviceObjUpdateModificationImpact(virNodeDeviceObj *obj,
+ unsigned int *flags);
typedef int
(*virDrvNodeDeviceIsActive)(virNodeDevicePtr dev);
+typedef int
+(*virDrvNodeDeviceUpdate)(virNodeDevicePtr dev,
+ const char *xmlDesc,
+ unsigned int flags);
+
typedef int
(*virDrvConnectNodeDeviceEventRegisterAny)(virConnectPtr conn,
virNodeDevicePtr dev,
virDrvNodeDeviceGetAutostart nodeDeviceGetAutostart;
virDrvNodeDeviceIsPersistent nodeDeviceIsPersistent;
virDrvNodeDeviceIsActive nodeDeviceIsActive;
+ virDrvNodeDeviceUpdate nodeDeviceUpdate;
};
virDispatchError(dev->conn);
return -1;
}
+
+
+/**
+ * virNodeDeviceUpdate:
+ * @dev: pointer to the node device object
+ * @xmlDesc: string containing an XML description of the device to be defined
+ * @flags: bitwise OR of virNodeDeviceUpdateFlags
+ *
+ * Update the definition of an existing node device, either its live running
+ * configuration, its persistent configuration, or both.
+ *
+ * Returns 0 in case of success, -1 in case of error
+ *
+ * Since: 10.1.0
+ */
+int
+virNodeDeviceUpdate(virNodeDevicePtr dev,
+ const char *xmlDesc,
+ unsigned int flags)
+{
+ VIR_DEBUG("nodeDevice=%p, xmlDesc=%s, flags=0x%x",
+ dev, NULLSTR(xmlDesc), flags);
+
+ virResetLastError();
+
+ virCheckNodeDeviceReturn(dev, -1);
+
+ virCheckReadOnlyGoto(dev->conn->flags, error);
+ virCheckNonNullArgGoto(xmlDesc, error);
+
+ if (dev->conn->nodeDeviceDriver &&
+ dev->conn->nodeDeviceDriver->nodeDeviceUpdate) {
+ int retval = dev->conn->nodeDeviceDriver->nodeDeviceUpdate(dev, xmlDesc, flags);
+ if (retval < 0)
+ goto error;
+
+ return 0;
+ }
+
+ virReportUnsupportedError();
+
+ error:
+ virDispatchError(dev->conn);
+ return -1;
+}
virNodeDeviceObjSetActive;
virNodeDeviceObjSetAutostart;
virNodeDeviceObjSetPersistent;
+virNodeDeviceObjUpdateModificationImpact;
# conf/virnwfilterbindingdef.h
virNetworkSetMetadata;
} LIBVIRT_9.0.0;
+LIBVIRT_10.1.0 {
+ global:
+ virNodeDeviceUpdate;
+} LIBVIRT_9.7.0;
+
# .... define new API here using predicted next version number ....
.nodeDeviceSetAutostart = remoteNodeDeviceSetAutostart, /* 7.8.0 */
.nodeDeviceIsPersistent = remoteNodeDeviceIsPersistent, /* 7.8.0 */
.nodeDeviceIsActive = remoteNodeDeviceIsActive, /* 7.8.0 */
+ .nodeDeviceUpdate = remoteNodeDeviceUpdate, /* 10.1.0 */
};
static virNWFilterDriver nwfilter_driver = {
int active;
};
+struct remote_node_device_update_args {
+ remote_nonnull_string name;
+ remote_nonnull_string xml_desc;
+ unsigned int flags;
+};
+
/*
* Events Register/Deregister:
* @generate: both
* @acl: none
*/
- REMOTE_PROC_NETWORK_EVENT_CALLBACK_METADATA_CHANGE = 446
+ REMOTE_PROC_NETWORK_EVENT_CALLBACK_METADATA_CHANGE = 446,
+
+ /**
+ * @generate: both
+ * @priority: high
+ * @acl: node_device:write
+ * @acl: node_device:save:!VIR_NODE_DEVICE_UPDATE_AFFECT_CONFIG|VIR_NODE_DEVICE_UPDATE_AFFECT_LIVE
+ * @acl: node_device:save:VIR_NODE_DEVICE_UPDATE_AFFECT_CONFIG
+ */
+ REMOTE_PROC_NODE_DEVICE_UPDATE = 447
};
struct remote_node_device_is_active_ret {
int active;
};
+struct remote_node_device_update_args {
+ remote_nonnull_string name;
+ remote_nonnull_string xml_desc;
+ u_int flags;
+};
struct remote_connect_domain_event_register_ret {
int cb_registered;
};
REMOTE_PROC_NETWORK_SET_METADATA = 444,
REMOTE_PROC_NETWORK_GET_METADATA = 445,
REMOTE_PROC_NETWORK_EVENT_CALLBACK_METADATA_CHANGE = 446,
+ REMOTE_PROC_NODE_DEVICE_UPDATE = 447,
};