
On Fri, Apr 24, 2009 at 02:28:37PM +0200, Daniel Veillard wrote:
diff -r 2d1278bdf31f qemud/remote_dispatch_table.h --- a/qemud/remote_dispatch_table.h Fri Apr 24 11:01:11 2009 +0100 +++ b/qemud/remote_dispatch_table.h Fri Apr 24 13:06:12 2009 +0100 [...] -{ /* DomainGetSecurityLabel => 118 */ +{ /* DomainGetSecurityLabel => 121 */ [...] -{ /* NodeGetSecurityModel => 119 */ +{ /* NodeGetSecurityModel => 122 */
Any reason for the renumbering even though it seems harmless ?
That's a bug in the current code in CVS - result of a merge mistake. It is harmless because this is just a comment.
+/** + * virNodeDeviceCreateXML: + * @conn: pointer to the hypervisor connection + * @xmlDesc: string containing an XML description of the device to be created + * @flags: callers should always pass 0 + * + * Create a new device on the VM host machine, for example, virtual + * HBAs created using vport_create. + * + * Returns a node device object if successful, NULL in case of failure + */ +virNodeDevicePtr +virNodeDeviceCreateXML(virConnectPtr conn, + const char *xmlDesc, + unsigned int flags) +{ + VIR_DEBUG("conn=%p, xmlDesc=%s, flags=%d", conn, xmlDesc, flags); + + virResetLastError(); + + if (!VIR_IS_CONNECT(conn)) { + virLibConnError(NULL, VIR_ERR_INVALID_CONN, __FUNCTION__); + return NULL; + } + + if (conn->flags & VIR_CONNECT_RO) { + virLibConnError(conn, VIR_ERR_OPERATION_DENIED, __FUNCTION__); + goto error; + } + + if (xmlDesc == NULL) { + virLibConnError(conn, VIR_ERR_INVALID_ARG, __FUNCTION__); + goto error; + } + + if (conn->deviceMonitor->deviceCreateXML) {
are we always 100% sure conn->deviceMonitor is non NULL ?
Yep, that needs an additional check 'conn->deviceMonitor != NULL'
+ virNodeDevicePtr dev = conn->deviceMonitor->deviceCreateXML(conn, xmlDesc, flags); + if (dev == NULL) + goto error; + return dev; + } + + virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__); + +error: + /* Copy to connection error object for back compatability */ + virSetConnError(conn); + return NULL; +} + + +/** + * virNodeDeviceDestroy: + * @dev: a device object + * + * Destroy the device object. The virtual device is removed from the host operating system. + * This function may require privileged access + * + * Returns 0 in case of success and -1 in case of failure. + */ +int +virNodeDeviceDestroy(virNodeDevicePtr dev) +{ + int retval = 0; + + DEBUG("dev=%p", dev); + + virResetLastError(); + + if (!VIR_IS_CONNECTED_NODE_DEVICE(dev)) { + virLibNodeDeviceError(NULL, VIR_ERR_INVALID_NODE_DEVICE, __FUNCTION__); + return (-1); + } + + if (dev->conn->flags & VIR_CONNECT_RO) { + virLibConnError(dev->conn, VIR_ERR_OPERATION_DENIED, __FUNCTION__); + goto error; + } + + if (dev->conn->deviceMonitor->deviceDestroy) { + retval = dev->conn->deviceMonitor->deviceDestroy(dev); + if (retval < 0) { + goto error; + } + + return 0; + } + + virLibConnError (dev->conn, VIR_ERR_NO_SUPPORT, __FUNCTION__); + +error: + /* Copy to connection error object for back compatability */ + virSetConnError(dev->conn); + return -1; +} + +
Likewise this needs a check for deviceMOnitor != NULL Daniel -- |: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|