This covers functions that return single wrapped objects and don't involve complexer code in the body. --- daemon/remote.c | 1212 ----------------------------------- daemon/remote_dispatch_bodies.c | 1198 +++++++++++++++++++++++++++++++++- daemon/remote_dispatch_prototypes.h | 4 +- daemon/remote_dispatch_table.h | 8 +- daemon/remote_generator.pl | 227 ++++--- 5 files changed, 1309 insertions(+), 1340 deletions(-) diff --git a/daemon/remote.c b/daemon/remote.c index a588a08..2b0e0dc 100644 --- a/daemon/remote.c +++ b/daemon/remote.c @@ -606,36 +606,6 @@ cleanup: return rv; } - -static int -remoteDispatchNodeGetFreeMemory(struct qemud_server *server ATTRIBUTE_UNUSED, - struct qemud_client *client ATTRIBUTE_UNUSED, - virConnectPtr conn, - remote_message_header *hdr ATTRIBUTE_UNUSED, - remote_error *rerr, - void *args ATTRIBUTE_UNUSED, - remote_node_get_free_memory_ret *ret) -{ - unsigned long long freeMem; - int rv = -1; - - if (!conn) { - virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open")); - goto cleanup; - } - - if ((freeMem = virNodeGetFreeMemory(conn)) == 0) - goto cleanup; - ret->freeMem = freeMem; - rv = 0; - -cleanup: - if (rv < 0) - remoteDispatchError(rerr); - return rv; -} - - static int remoteDispatchDomainGetSchedulerType(struct qemud_server *server ATTRIBUTE_UNUSED, struct qemud_client *client ATTRIBUTE_UNUSED, @@ -1118,70 +1088,6 @@ cleanup: } static int -remoteDispatchDomainCreateXML(struct qemud_server *server ATTRIBUTE_UNUSED, - struct qemud_client *client ATTRIBUTE_UNUSED, - virConnectPtr conn, - remote_message_header *hdr ATTRIBUTE_UNUSED, - remote_error *rerr, - remote_domain_create_xml_args *args, - remote_domain_create_xml_ret *ret) -{ - virDomainPtr dom = NULL; - int rv = -1; - - if (!conn) { - virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open")); - goto cleanup; - } - - if (!(dom = virDomainCreateXML(conn, args->xml_desc, args->flags))) - goto cleanup; - - make_nonnull_domain(&ret->dom, dom); - - rv = 0; - -cleanup: - if (rv < 0) - remoteDispatchError(rerr); - if (dom) - virDomainFree(dom); - return rv; -} - -static int -remoteDispatchDomainDefineXML(struct qemud_server *server ATTRIBUTE_UNUSED, - struct qemud_client *client ATTRIBUTE_UNUSED, - virConnectPtr conn, - remote_message_header *hdr ATTRIBUTE_UNUSED, - remote_error *rerr, - remote_domain_define_xml_args *args, - remote_domain_define_xml_ret *ret) -{ - virDomainPtr dom = NULL; - int rv = -1; - - if (!conn) { - virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open")); - goto cleanup; - } - - if (!(dom = virDomainDefineXML(conn, args->xml))) - goto cleanup; - - make_nonnull_domain(&ret->dom, dom); - - rv = 0; - -cleanup: - if (rv < 0) - remoteDispatchError(rerr); - if (dom) - virDomainFree(dom); - return rv; -} - -static int remoteDispatchDomainGetInfo(struct qemud_server *server ATTRIBUTE_UNUSED, struct qemud_client *client ATTRIBUTE_UNUSED, virConnectPtr conn, @@ -1492,41 +1398,6 @@ cleanup: } static int -remoteDispatchDomainMigrateFinish(struct qemud_server *server ATTRIBUTE_UNUSED, - struct qemud_client *client ATTRIBUTE_UNUSED, - virConnectPtr conn, - remote_message_header *hdr ATTRIBUTE_UNUSED, - remote_error *rerr, - remote_domain_migrate_finish_args *args, - remote_domain_migrate_finish_ret *ret) -{ - virDomainPtr dom = NULL; - int rv = -1; - - if (!conn) { - virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open")); - goto cleanup; - } - - if (!(dom = virDomainMigrateFinish(conn, args->dname, - args->cookie.cookie_val, - args->cookie.cookie_len, - args->uri, - args->flags))) - goto cleanup; - - make_nonnull_domain(&ret->ddom, dom); - rv = 0; - -cleanup: - if (rv < 0) - remoteDispatchError(rerr); - if (dom) - virDomainFree(dom); - return rv; -} - -static int remoteDispatchDomainMigratePrepare2(struct qemud_server *server ATTRIBUTE_UNUSED, struct qemud_client *client ATTRIBUTE_UNUSED, virConnectPtr conn, @@ -1578,43 +1449,6 @@ cleanup: } static int -remoteDispatchDomainMigrateFinish2(struct qemud_server *server ATTRIBUTE_UNUSED, - struct qemud_client *client ATTRIBUTE_UNUSED, - virConnectPtr conn, - remote_message_header *hdr ATTRIBUTE_UNUSED, - remote_error *rerr, - remote_domain_migrate_finish2_args *args, - remote_domain_migrate_finish2_ret *ret) -{ - virDomainPtr dom = NULL; - int rv = -1; - - if (!conn) { - virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open")); - goto cleanup; - } - - if (!(dom = virDomainMigrateFinish2(conn, args->dname, - args->cookie.cookie_val, - args->cookie.cookie_len, - args->uri, - args->flags, - args->retcode))) - goto cleanup; - - make_nonnull_domain(&ret->ddom, dom); - - rv = 0; - -cleanup: - if (rv < 0) - remoteDispatchError(rerr); - if (dom) - virDomainFree(dom); - return rv; -} - -static int remoteDispatchDomainMigratePrepareTunnel(struct qemud_server *server ATTRIBUTE_UNUSED, struct qemud_client *client, virConnectPtr conn, @@ -1706,102 +1540,6 @@ cleanup: } static int -remoteDispatchDomainLookupById(struct qemud_server *server ATTRIBUTE_UNUSED, - struct qemud_client *client ATTRIBUTE_UNUSED, - virConnectPtr conn, - remote_message_header *hdr ATTRIBUTE_UNUSED, - remote_error *rerr, - remote_domain_lookup_by_id_args *args, - remote_domain_lookup_by_id_ret *ret) -{ - virDomainPtr dom = NULL; - int rv = -1; - - if (!conn) { - virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open")); - goto cleanup; - } - - if (!(dom = virDomainLookupByID(conn, args->id))) - goto cleanup; - - make_nonnull_domain(&ret->dom, dom); - - rv = 0; - -cleanup: - if (rv < 0) - remoteDispatchError(rerr); - if (dom) - virDomainFree(dom); - return rv; -} - -static int -remoteDispatchDomainLookupByName(struct qemud_server *server ATTRIBUTE_UNUSED, - struct qemud_client *client ATTRIBUTE_UNUSED, - virConnectPtr conn, - remote_message_header *hdr ATTRIBUTE_UNUSED, - remote_error *rerr, - remote_domain_lookup_by_name_args *args, - remote_domain_lookup_by_name_ret *ret) -{ - virDomainPtr dom = NULL; - int rv = -1; - - if (!conn) { - virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open")); - goto cleanup; - } - - if (!(dom = virDomainLookupByName(conn, args->name))) - goto cleanup; - - make_nonnull_domain(&ret->dom, dom); - - rv = 0; - -cleanup: - if (rv < 0) - remoteDispatchError(rerr); - if (dom) - virDomainFree(dom); - return rv; -} - -static int -remoteDispatchDomainLookupByUUID(struct qemud_server *server ATTRIBUTE_UNUSED, - struct qemud_client *client ATTRIBUTE_UNUSED, - virConnectPtr conn, - remote_message_header *hdr ATTRIBUTE_UNUSED, - remote_error *rerr, - remote_domain_lookup_by_uuid_args *args, - remote_domain_lookup_by_uuid_ret *ret) -{ - virDomainPtr dom = NULL; - int rv = -1; - - if (!conn) { - virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open")); - goto cleanup; - } - - if (!(dom = virDomainLookupByUUID(conn, (unsigned char *) args->uuid))) - goto cleanup; - - make_nonnull_domain(&ret->dom, dom); - - rv = 0; - -cleanup: - if (rv < 0) - remoteDispatchError(rerr); - if (dom) - virDomainFree(dom); - return rv; -} - -static int remoteDispatchDomainPinVcpu(struct qemud_server *server ATTRIBUTE_UNUSED, struct qemud_client *client ATTRIBUTE_UNUSED, virConnectPtr conn, @@ -2408,134 +2146,6 @@ cleanup: return rv; } -static int -remoteDispatchNetworkCreateXML(struct qemud_server *server ATTRIBUTE_UNUSED, - struct qemud_client *client ATTRIBUTE_UNUSED, - virConnectPtr conn, - remote_message_header *hdr ATTRIBUTE_UNUSED, - remote_error *rerr, - remote_network_create_xml_args *args, - remote_network_create_xml_ret *ret) -{ - virNetworkPtr net = NULL; - int rv = -1; - - if (!conn) { - virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open")); - goto cleanup; - } - - if (!(net = virNetworkCreateXML(conn, args->xml))) - goto cleanup; - - make_nonnull_network(&ret->net, net); - - rv = 0; - -cleanup: - if (rv < 0) - remoteDispatchError(rerr); - if (net) - virNetworkFree(net); - return rv; -} - -static int -remoteDispatchNetworkDefineXML(struct qemud_server *server ATTRIBUTE_UNUSED, - struct qemud_client *client ATTRIBUTE_UNUSED, - virConnectPtr conn, - remote_message_header *hdr ATTRIBUTE_UNUSED, - remote_error *rerr, - remote_network_define_xml_args *args, - remote_network_define_xml_ret *ret) -{ - virNetworkPtr net = NULL; - int rv = -1; - - if (!conn) { - virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open")); - goto cleanup; - } - - if (!(net = virNetworkDefineXML(conn, args->xml))) - goto cleanup; - - make_nonnull_network(&ret->net, net); - - rv = 0; - -cleanup: - if (rv < 0) - remoteDispatchError(rerr); - if (net) - virNetworkFree(net); - return rv; -} - -static int -remoteDispatchNetworkLookupByName(struct qemud_server *server ATTRIBUTE_UNUSED, - struct qemud_client *client ATTRIBUTE_UNUSED, - virConnectPtr conn, - remote_message_header *hdr ATTRIBUTE_UNUSED, - remote_error *rerr, - remote_network_lookup_by_name_args *args, - remote_network_lookup_by_name_ret *ret) -{ - virNetworkPtr net = NULL; - int rv = -1; - - if (!conn) { - virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open")); - goto cleanup; - } - - if (!(net = virNetworkLookupByName(conn, args->name))) - goto cleanup; - - make_nonnull_network(&ret->net, net); - - rv = 0; - -cleanup: - if (rv < 0) - remoteDispatchError(rerr); - if (net) - virNetworkFree(net); - return rv; -} - -static int -remoteDispatchNetworkLookupByUUID(struct qemud_server *server ATTRIBUTE_UNUSED, - struct qemud_client *client ATTRIBUTE_UNUSED, - virConnectPtr conn, - remote_message_header *hdr ATTRIBUTE_UNUSED, - remote_error *rerr, - remote_network_lookup_by_uuid_args *args, - remote_network_lookup_by_uuid_ret *ret) -{ - virNetworkPtr net = NULL; - int rv = -1; - - if (!conn) { - virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open")); - goto cleanup; - } - - if (!(net = virNetworkLookupByUUID(conn, (unsigned char *) args->uuid))) - goto cleanup; - - make_nonnull_network(&ret->net, net); - - rv = 0; - -cleanup: - if (rv < 0) - remoteDispatchError(rerr); - if (net) - virNetworkFree(net); - return rv; -} - /*-------------------------------------------------------------*/ static int @@ -2628,102 +2238,6 @@ cleanup: return rv; } -static int -remoteDispatchInterfaceLookupByName(struct qemud_server *server ATTRIBUTE_UNUSED, - struct qemud_client *client ATTRIBUTE_UNUSED, - virConnectPtr conn, - remote_message_header *hdr ATTRIBUTE_UNUSED, - remote_error *rerr, - remote_interface_lookup_by_name_args *args, - remote_interface_lookup_by_name_ret *ret) -{ - virInterfacePtr iface = NULL; - int rv = -1; - - if (!conn) { - virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open")); - goto cleanup; - } - - if (!(iface = virInterfaceLookupByName(conn, args->name))) - goto cleanup; - - make_nonnull_interface(&ret->iface, iface); - - rv = 0; - -cleanup: - if (rv < 0) - remoteDispatchError(rerr); - if (iface) - virInterfaceFree(iface); - return rv; -} - -static int -remoteDispatchInterfaceLookupByMacString(struct qemud_server *server ATTRIBUTE_UNUSED, - struct qemud_client *client ATTRIBUTE_UNUSED, - virConnectPtr conn, - remote_message_header *hdr ATTRIBUTE_UNUSED, - remote_error *rerr, - remote_interface_lookup_by_mac_string_args *args, - remote_interface_lookup_by_mac_string_ret *ret) -{ - virInterfacePtr iface = NULL; - int rv = -1; - - if (!conn) { - virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open")); - goto cleanup; - } - - if (!(iface = virInterfaceLookupByMACString(conn, args->mac))) - goto cleanup; - - make_nonnull_interface(&ret->iface, iface); - - rv = 0; - -cleanup: - if (rv < 0) - remoteDispatchError(rerr); - if (iface) - virInterfaceFree(iface); - return rv; -} - -static int -remoteDispatchInterfaceDefineXML(struct qemud_server *server ATTRIBUTE_UNUSED, - struct qemud_client *client ATTRIBUTE_UNUSED, - virConnectPtr conn, - remote_message_header *hdr ATTRIBUTE_UNUSED, - remote_error *rerr, - remote_interface_define_xml_args *args, - remote_interface_define_xml_ret *ret) -{ - virInterfacePtr iface = NULL; - int rv = -1; - - if (!conn) { - virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open")); - goto cleanup; - } - - if (!(iface = virInterfaceDefineXML(conn, args->xml, args->flags))) - goto cleanup; - - make_nonnull_interface(&ret->iface, iface); - - rv = 0; - -cleanup: - if (rv < 0) - remoteDispatchError(rerr); - if (iface) - virInterfaceFree(iface); - return rv; -} - /*-------------------------------------------------------------*/ static int @@ -3651,70 +3165,6 @@ cleanup: } static int -remoteDispatchStoragePoolCreateXML(struct qemud_server *server ATTRIBUTE_UNUSED, - struct qemud_client *client ATTRIBUTE_UNUSED, - virConnectPtr conn, - remote_message_header *hdr ATTRIBUTE_UNUSED, - remote_error *rerr, - remote_storage_pool_create_xml_args *args, - remote_storage_pool_create_xml_ret *ret) -{ - virStoragePoolPtr pool = NULL; - int rv = -1; - - if (!conn) { - virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open")); - goto cleanup; - } - - if (!(pool = virStoragePoolCreateXML(conn, args->xml, args->flags))) - goto cleanup; - - make_nonnull_storage_pool(&ret->pool, pool); - - rv = 0; - -cleanup: - if (rv < 0) - remoteDispatchError(rerr); - if (pool) - virStoragePoolFree(pool); - return rv; -} - -static int -remoteDispatchStoragePoolDefineXML(struct qemud_server *server ATTRIBUTE_UNUSED, - struct qemud_client *client ATTRIBUTE_UNUSED, - virConnectPtr conn, - remote_message_header *hdr ATTRIBUTE_UNUSED, - remote_error *rerr, - remote_storage_pool_define_xml_args *args, - remote_storage_pool_define_xml_ret *ret) -{ - virStoragePoolPtr pool = NULL; - int rv = -1; - - if (!conn) { - virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open")); - goto cleanup; - } - - if (!(pool = virStoragePoolDefineXML(conn, args->xml, args->flags))) - goto cleanup; - - make_nonnull_storage_pool(&ret->pool, pool); - - rv = 0; - -cleanup: - if (rv < 0) - remoteDispatchError(rerr); - if (pool) - virStoragePoolFree(pool); - return rv; -} - -static int remoteDispatchStoragePoolGetInfo(struct qemud_server *server ATTRIBUTE_UNUSED, struct qemud_client *client ATTRIBUTE_UNUSED, virConnectPtr conn, @@ -3754,108 +3204,6 @@ cleanup: } static int -remoteDispatchStoragePoolLookupByName(struct qemud_server *server ATTRIBUTE_UNUSED, - struct qemud_client *client ATTRIBUTE_UNUSED, - virConnectPtr conn, - remote_message_header *hdr ATTRIBUTE_UNUSED, - remote_error *rerr, - remote_storage_pool_lookup_by_name_args *args, - remote_storage_pool_lookup_by_name_ret *ret) -{ - virStoragePoolPtr pool = NULL; - int rv = -1; - - if (!conn) { - virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open")); - goto cleanup; - } - - if (!(pool = virStoragePoolLookupByName(conn, args->name))) - goto cleanup; - - make_nonnull_storage_pool(&ret->pool, pool); - - rv = 0; - -cleanup: - if (rv < 0) - remoteDispatchError(rerr); - if (pool) - virStoragePoolFree(pool); - return rv; -} - -static int -remoteDispatchStoragePoolLookupByUUID(struct qemud_server *server ATTRIBUTE_UNUSED, - struct qemud_client *client ATTRIBUTE_UNUSED, - virConnectPtr conn, - remote_message_header *hdr ATTRIBUTE_UNUSED, - remote_error *rerr, - remote_storage_pool_lookup_by_uuid_args *args, - remote_storage_pool_lookup_by_uuid_ret *ret) -{ - virStoragePoolPtr pool = NULL; - int rv = -1; - - if (!conn) { - virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open")); - goto cleanup; - } - - if (!(pool = virStoragePoolLookupByUUID(conn, (unsigned char *) args->uuid))) - goto cleanup; - - make_nonnull_storage_pool(&ret->pool, pool); - - rv = 0; - -cleanup: - if (rv < 0) - remoteDispatchError(rerr); - if (pool) - virStoragePoolFree(pool); - return rv; -} - -static int -remoteDispatchStoragePoolLookupByVolume(struct qemud_server *server ATTRIBUTE_UNUSED, - struct qemud_client *client ATTRIBUTE_UNUSED, - virConnectPtr conn, - remote_message_header *hdr ATTRIBUTE_UNUSED, - remote_error *rerr, - remote_storage_pool_lookup_by_volume_args *args, - remote_storage_pool_lookup_by_volume_ret *ret) -{ - virStoragePoolPtr pool = NULL; - virStorageVolPtr vol = NULL; - int rv = -1; - - if (!conn) { - virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open")); - goto cleanup; - } - - if (!(vol = get_nonnull_storage_vol(conn, args->vol))) - goto cleanup; - - if (!(pool = virStoragePoolLookupByVolume(vol))) - goto cleanup; - - make_nonnull_storage_pool(&ret->pool, pool); - - rv = 0; - -cleanup: - if (rv < 0) - remoteDispatchError(rerr); - if (vol) - virStorageVolFree(vol); - if (pool) - virStoragePoolFree(pool); - return rv; -} - -static int remoteDispatchStoragePoolListVolumes(struct qemud_server *server ATTRIBUTE_UNUSED, struct qemud_client *client ATTRIBUTE_UNUSED, virConnectPtr conn, @@ -3911,89 +3259,6 @@ cleanup: * STORAGE VOL APIS ***************************************************************/ - - -static int -remoteDispatchStorageVolCreateXML(struct qemud_server *server ATTRIBUTE_UNUSED, - struct qemud_client *client ATTRIBUTE_UNUSED, - virConnectPtr conn, - remote_message_header *hdr ATTRIBUTE_UNUSED, - remote_error *rerr, - remote_storage_vol_create_xml_args *args, - remote_storage_vol_create_xml_ret *ret) -{ - virStoragePoolPtr pool = NULL; - virStorageVolPtr vol = NULL; - int rv = -1; - - if (!conn) { - virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open")); - goto cleanup; - } - - if (!(pool = get_nonnull_storage_pool(conn, args->pool))) - goto cleanup; - - if (!(vol = virStorageVolCreateXML(pool, args->xml, args->flags))) - goto cleanup; - - make_nonnull_storage_vol(&ret->vol, vol); - rv = 0; - -cleanup: - if (rv < 0) - remoteDispatchError(rerr); - if (pool) - virStoragePoolFree(pool); - if (vol) - virStorageVolFree(vol); - return rv; -} - -static int -remoteDispatchStorageVolCreateXMLFrom(struct qemud_server *server ATTRIBUTE_UNUSED, - struct qemud_client *client ATTRIBUTE_UNUSED, - virConnectPtr conn, - remote_message_header *hdr ATTRIBUTE_UNUSED, - remote_error *rerr, - remote_storage_vol_create_xml_from_args *args, - remote_storage_vol_create_xml_from_ret *ret) -{ - virStoragePoolPtr pool = NULL; - virStorageVolPtr clonevol = NULL; - virStorageVolPtr newvol = NULL; - int rv = -1; - - if (!conn) { - virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open")); - goto cleanup; - } - - if (!(pool = get_nonnull_storage_pool(conn, args->pool))) - goto cleanup; - - if (!(clonevol = get_nonnull_storage_vol(conn, args->clonevol))) - goto cleanup; - - if (!(newvol = virStorageVolCreateXMLFrom(pool, args->xml, clonevol, - args->flags))) - goto cleanup; - - make_nonnull_storage_vol(&ret->vol, newvol); - rv = 0; - -cleanup: - if (rv < 0) - remoteDispatchError(rerr); - if (newvol) - virStorageVolFree(newvol); - if (clonevol) - virStorageVolFree(clonevol); - if (pool) - virStoragePoolFree(pool); - return rv; -} - static int remoteDispatchStorageVolGetInfo(struct qemud_server *server ATTRIBUTE_UNUSED, struct qemud_client *client ATTRIBUTE_UNUSED, @@ -4032,110 +3297,6 @@ cleanup: return rv; } -static int -remoteDispatchStorageVolLookupByName(struct qemud_server *server ATTRIBUTE_UNUSED, - struct qemud_client *client ATTRIBUTE_UNUSED, - virConnectPtr conn, - remote_message_header *hdr ATTRIBUTE_UNUSED, - remote_error *rerr, - remote_storage_vol_lookup_by_name_args *args, - remote_storage_vol_lookup_by_name_ret *ret) -{ - virStoragePoolPtr pool = NULL; - virStorageVolPtr vol = NULL; - int rv = -1; - - if (!conn) { - virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open")); - goto cleanup; - } - - if (!(pool = get_nonnull_storage_pool(conn, args->pool))) - goto cleanup; - - if (!(vol = virStorageVolLookupByName(pool, args->name))) - goto cleanup; - - make_nonnull_storage_vol(&ret->vol, vol); - - rv = 0; - -cleanup: - if (rv < 0) - remoteDispatchError(rerr); - if (pool) - virStoragePoolFree(pool); - if (vol) - virStorageVolFree(vol); - return rv; -} - -static int -remoteDispatchStorageVolLookupByKey(struct qemud_server *server ATTRIBUTE_UNUSED, - struct qemud_client *client ATTRIBUTE_UNUSED, - virConnectPtr conn, - remote_message_header *hdr ATTRIBUTE_UNUSED, - remote_error *rerr, - remote_storage_vol_lookup_by_key_args *args, - remote_storage_vol_lookup_by_key_ret *ret) -{ - virStorageVolPtr vol = NULL; - int rv = -1; - - if (!conn) { - virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open")); - goto cleanup; - } - - if (!(vol = virStorageVolLookupByKey(conn, args->key))) - goto cleanup; - - make_nonnull_storage_vol(&ret->vol, vol); - - rv = 0; - -cleanup: - if (rv < 0) - remoteDispatchError(rerr); - if (vol) - virStorageVolFree(vol); - return rv; -} - - -static int -remoteDispatchStorageVolLookupByPath(struct qemud_server *server ATTRIBUTE_UNUSED, - struct qemud_client *client ATTRIBUTE_UNUSED, - virConnectPtr conn, - remote_message_header *hdr ATTRIBUTE_UNUSED, - remote_error *rerr, - remote_storage_vol_lookup_by_path_args *args, - remote_storage_vol_lookup_by_path_ret *ret) -{ - virStorageVolPtr vol = NULL; - int rv = -1; - - if (!conn) { - virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open")); - goto cleanup; - } - - if (!(vol = virStorageVolLookupByPath(conn, args->path))) - goto cleanup; - - make_nonnull_storage_vol(&ret->vol, vol); - - rv = 0; - -cleanup: - if (rv < 0) - remoteDispatchError(rerr); - if (vol) - virStorageVolFree(vol); - return rv; -} - - /*************************************************************** * NODE INFO APIS **************************************************************/ @@ -4216,39 +3377,6 @@ cleanup: return rv; } - -static int -remoteDispatchNodeDeviceLookupByName(struct qemud_server *server ATTRIBUTE_UNUSED, - struct qemud_client *client ATTRIBUTE_UNUSED, - virConnectPtr conn, - remote_message_header *hdr ATTRIBUTE_UNUSED, - remote_error *rerr, - remote_node_device_lookup_by_name_args *args, - remote_node_device_lookup_by_name_ret *ret) -{ - virNodeDevicePtr dev = NULL; - int rv = -1; - - if (!conn) { - virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open")); - goto cleanup; - } - - if (!(dev = virNodeDeviceLookupByName(conn, args->name))) - goto cleanup; - - make_nonnull_node_device(&ret->dev, dev); - - rv = 0; - -cleanup: - if (rv < 0) - remoteDispatchError(rerr); - if (dev) - virNodeDeviceFree(dev); - return rv; -} - static int remoteDispatchNodeDeviceGetParent(struct qemud_server *server ATTRIBUTE_UNUSED, struct qemud_client *client ATTRIBUTE_UNUSED, @@ -4350,38 +3478,6 @@ cleanup: return rv; } -static int -remoteDispatchNodeDeviceCreateXML(struct qemud_server *server ATTRIBUTE_UNUSED, - struct qemud_client *client ATTRIBUTE_UNUSED, - virConnectPtr conn, - remote_message_header *hdr ATTRIBUTE_UNUSED, - remote_error *rerr, - remote_node_device_create_xml_args *args, - remote_node_device_create_xml_ret *ret) -{ - virNodeDevicePtr dev = NULL; - int rv = -1; - - if (!conn) { - virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open")); - goto cleanup; - } - - if (!(dev = virNodeDeviceCreateXML(conn, args->xml_desc, args->flags))) - goto cleanup; - - make_nonnull_node_device(&ret->dev, dev); - - rv = 0; - -cleanup: - if (rv < 0) - remoteDispatchError(rerr); - if (dev) - virNodeDeviceFree(dev); - return rv; -} - static int remoteDispatchStorageVolUpload(struct qemud_server *server ATTRIBUTE_UNUSED, struct qemud_client *client, virConnectPtr conn, @@ -4658,37 +3754,6 @@ cleanup: } static int -remoteDispatchSecretDefineXML(struct qemud_server *server ATTRIBUTE_UNUSED, - struct qemud_client *client ATTRIBUTE_UNUSED, - virConnectPtr conn, - remote_message_header *hdr ATTRIBUTE_UNUSED, - remote_error *rerr, - remote_secret_define_xml_args *args, - remote_secret_define_xml_ret *ret) -{ - virSecretPtr secret = NULL; - int rv = -1; - - if (!conn) { - virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open")); - goto cleanup; - } - - if (!(secret = virSecretDefineXML(conn, args->xml, args->flags))) - goto cleanup; - - make_nonnull_secret(&ret->secret, secret); - rv = 0; - -cleanup: - if (rv < 0) - remoteDispatchError(rerr); - if (secret) - virSecretFree(secret); - return rv; -} - -static int remoteDispatchSecretGetValue(struct qemud_server *server ATTRIBUTE_UNUSED, struct qemud_client *client ATTRIBUTE_UNUSED, virConnectPtr conn, @@ -4727,70 +3792,6 @@ cleanup: } static int -remoteDispatchSecretLookupByUUID(struct qemud_server *server ATTRIBUTE_UNUSED, - struct qemud_client *client ATTRIBUTE_UNUSED, - virConnectPtr conn, - remote_message_header *hdr ATTRIBUTE_UNUSED, - remote_error *rerr, - remote_secret_lookup_by_uuid_args *args, - remote_secret_lookup_by_uuid_ret *ret) -{ - virSecretPtr secret = NULL; - int rv = -1; - - if (!conn) { - virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open")); - goto cleanup; - } - - if (!(secret = virSecretLookupByUUID(conn, (unsigned char *)args->uuid))) - goto cleanup; - - make_nonnull_secret(&ret->secret, secret); - - rv = 0; - -cleanup: - if (rv < 0) - remoteDispatchError(rerr); - if (secret) - virSecretFree(secret); - return rv; -} - -static int -remoteDispatchSecretLookupByUsage(struct qemud_server *server ATTRIBUTE_UNUSED, - struct qemud_client *client ATTRIBUTE_UNUSED, - virConnectPtr conn, - remote_message_header *hdr ATTRIBUTE_UNUSED, - remote_error *rerr, - remote_secret_lookup_by_usage_args *args, - remote_secret_lookup_by_usage_ret *ret) -{ - virSecretPtr secret = NULL; - int rv = -1; - - if (!conn) { - virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open")); - goto cleanup; - } - - if (!(secret = virSecretLookupByUsage(conn, args->usageType, args->usageID))) - goto cleanup; - - make_nonnull_secret(&ret->secret, secret); - - rv = 0; - -cleanup: - if (rv < 0) - remoteDispatchError(rerr); - if (secret) - virSecretFree(secret); - return rv; -} - -static int remoteDispatchCpuCompare(struct qemud_server *server ATTRIBUTE_UNUSED, struct qemud_client *client ATTRIBUTE_UNUSED, virConnectPtr conn, @@ -4902,44 +3903,6 @@ cleanup: } static int -remoteDispatchDomainSnapshotCreateXML(struct qemud_server *server ATTRIBUTE_UNUSED, - struct qemud_client *client ATTRIBUTE_UNUSED, - virConnectPtr conn, - remote_message_header *hdr ATTRIBUTE_UNUSED, - remote_error *rerr, - remote_domain_snapshot_create_xml_args *args, - remote_domain_snapshot_create_xml_ret *ret) -{ - virDomainSnapshotPtr snapshot = NULL; - virDomainPtr dom = NULL; - int rv = -1; - - if (!conn) { - virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open")); - goto cleanup; - } - - if (!(dom = get_nonnull_domain(conn, args->dom))) - goto cleanup; - - if (!(snapshot = virDomainSnapshotCreateXML(dom, args->xml_desc, args->flags))) - goto cleanup; - - make_nonnull_domain_snapshot(&ret->snap, snapshot); - - rv = 0; - -cleanup: - if (rv < 0) - remoteDispatchError(rerr); - if (snapshot) - virDomainSnapshotFree(snapshot); - if (dom) - virDomainFree(dom); - return rv; -} - -static int remoteDispatchDomainSnapshotListNames(struct qemud_server *server ATTRIBUTE_UNUSED, struct qemud_client *client ATTRIBUTE_UNUSED, virConnectPtr conn, @@ -4993,82 +3956,6 @@ cleanup: } static int -remoteDispatchDomainSnapshotLookupByName(struct qemud_server *server ATTRIBUTE_UNUSED, - struct qemud_client *client ATTRIBUTE_UNUSED, - virConnectPtr conn, - remote_message_header *hdr ATTRIBUTE_UNUSED, - remote_error *rerr, - remote_domain_snapshot_lookup_by_name_args *args, - remote_domain_snapshot_lookup_by_name_ret *ret) -{ - virDomainSnapshotPtr snapshot = NULL; - virDomainPtr dom = NULL; - int rv = -1; - - if (!conn) { - virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open")); - goto cleanup; - } - - if (!(dom = get_nonnull_domain(conn, args->dom))) - goto cleanup; - - if (!(snapshot = virDomainSnapshotLookupByName(dom, args->name, args->flags))) - goto cleanup; - - make_nonnull_domain_snapshot(&ret->snap, snapshot); - - rv = 0; - -cleanup: - if (rv < 0) - remoteDispatchError(rerr); - if (snapshot) - virDomainSnapshotFree(snapshot); - if (dom) - virDomainFree(dom); - return rv; -} - -static int -remoteDispatchDomainSnapshotCurrent(struct qemud_server *server ATTRIBUTE_UNUSED, - struct qemud_client *client ATTRIBUTE_UNUSED, - virConnectPtr conn, - remote_message_header *hdr ATTRIBUTE_UNUSED, - remote_error *rerr, - remote_domain_snapshot_current_args *args, - remote_domain_snapshot_current_ret *ret) -{ - virDomainSnapshotPtr snapshot = NULL; - virDomainPtr dom = NULL; - int rv = -1; - - if (!conn) { - virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open")); - goto cleanup; - } - - if (!(dom = get_nonnull_domain(conn, args->dom))) - goto cleanup; - - if (!(snapshot = virDomainSnapshotCurrent(dom, args->flags))) - goto cleanup; - - make_nonnull_domain_snapshot(&ret->snap, snapshot); - - rv = 0; - -cleanup: - if (rv < 0) - remoteDispatchError(rerr); - if (snapshot) - virDomainSnapshotFree(snapshot); - if (dom) - virDomainFree(dom); - return rv; -} - -static int remoteDispatchDomainEventsRegisterAny(struct qemud_server *server ATTRIBUTE_UNUSED, struct qemud_client *client ATTRIBUTE_UNUSED, virConnectPtr conn, @@ -5154,105 +4041,6 @@ cleanup: return rv; } - - -static int -remoteDispatchNWFilterLookupByName(struct qemud_server *server ATTRIBUTE_UNUSED, - struct qemud_client *client ATTRIBUTE_UNUSED, - virConnectPtr conn, - remote_message_header *hdr ATTRIBUTE_UNUSED, - remote_error *rerr, - remote_nwfilter_lookup_by_name_args *args, - remote_nwfilter_lookup_by_name_ret *ret) -{ - virNWFilterPtr nwfilter = NULL; - int rv = -1; - - if (!conn) { - virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open")); - goto cleanup; - } - - if (!(nwfilter = virNWFilterLookupByName(conn, args->name))) - goto cleanup; - - make_nonnull_nwfilter(&ret->nwfilter, nwfilter); - - rv = 0; - -cleanup: - if (rv < 0) - remoteDispatchError(rerr); - if (nwfilter) - virNWFilterFree(nwfilter); - return rv; -} - -static int -remoteDispatchNWFilterLookupByUUID(struct qemud_server *server ATTRIBUTE_UNUSED, - struct qemud_client *client ATTRIBUTE_UNUSED, - virConnectPtr conn, - remote_message_header *hdr ATTRIBUTE_UNUSED, - remote_error *rerr, - remote_nwfilter_lookup_by_uuid_args *args, - remote_nwfilter_lookup_by_uuid_ret *ret) -{ - virNWFilterPtr nwfilter = NULL; - int rv = -1; - - if (!conn) { - virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open")); - goto cleanup; - } - - if (!(nwfilter = virNWFilterLookupByUUID(conn, (unsigned char *) args->uuid))) - goto cleanup; - - make_nonnull_nwfilter(&ret->nwfilter, nwfilter); - - rv = 0; - -cleanup: - if (rv < 0) - remoteDispatchError(rerr); - if (nwfilter) - virNWFilterFree(nwfilter); - return rv; -} - - -static int -remoteDispatchNWFilterDefineXML(struct qemud_server *server ATTRIBUTE_UNUSED, - struct qemud_client *client ATTRIBUTE_UNUSED, - virConnectPtr conn, - remote_message_header *hdr ATTRIBUTE_UNUSED, - remote_error *rerr, - remote_nwfilter_define_xml_args *args, - remote_nwfilter_define_xml_ret *ret) -{ - virNWFilterPtr nwfilter = NULL; - int rv = -1; - - if (!conn) { - virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open")); - goto cleanup; - } - - if (!(nwfilter = virNWFilterDefineXML(conn, args->xml))) - goto cleanup; - - make_nonnull_nwfilter(&ret->nwfilter, nwfilter); - - rv = 0; - -cleanup: - if (rv < 0) - remoteDispatchError(rerr); - if (nwfilter) - virNWFilterFree(nwfilter); - return rv; -} - static int remoteDispatchListNWFilters(struct qemud_server *server ATTRIBUTE_UNUSED, struct qemud_client *client ATTRIBUTE_UNUSED, diff --git a/daemon/remote_dispatch_bodies.c b/daemon/remote_dispatch_bodies.c index c1959b6..bd7cddd 100644 --- a/daemon/remote_dispatch_bodies.c +++ b/daemon/remote_dispatch_bodies.c @@ -194,9 +194,69 @@ cleanup: /* remoteDispatchDomainCreateWithFlags has to be implemented manually */ -/* remoteDispatchDomainCreateXML has to be implemented manually */ +static int +remoteDispatchDomainCreateXML( + struct qemud_server *server ATTRIBUTE_UNUSED, + struct qemud_client *client ATTRIBUTE_UNUSED, + virConnectPtr conn, + remote_message_header *hdr ATTRIBUTE_UNUSED, + remote_error *rerr, + remote_domain_create_xml_args *args, + remote_domain_create_xml_ret *ret) +{ + int rv = -1; + virDomainPtr dom = NULL; + + if (!conn) { + virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open")); + goto cleanup; + } -/* remoteDispatchDomainDefineXML has to be implemented manually */ + if ((dom = virDomainCreateXML(conn, args->xml_desc, args->flags)) == NULL) + goto cleanup; + + make_nonnull_domain(&ret->dom, dom); + rv = 0; + +cleanup: + if (rv < 0) + remoteDispatchError(rerr); + if (dom) + virDomainFree(dom); + return rv; +} + +static int +remoteDispatchDomainDefineXML( + struct qemud_server *server ATTRIBUTE_UNUSED, + struct qemud_client *client ATTRIBUTE_UNUSED, + virConnectPtr conn, + remote_message_header *hdr ATTRIBUTE_UNUSED, + remote_error *rerr, + remote_domain_define_xml_args *args, + remote_domain_define_xml_ret *ret) +{ + int rv = -1; + virDomainPtr dom = NULL; + + if (!conn) { + virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open")); + goto cleanup; + } + + if ((dom = virDomainDefineXML(conn, args->xml)) == NULL) + goto cleanup; + + make_nonnull_domain(&ret->dom, dom); + rv = 0; + +cleanup: + if (rv < 0) + remoteDispatchError(rerr); + if (dom) + virDomainFree(dom); + return rv; +} static int remoteDispatchDomainDestroy( @@ -724,11 +784,101 @@ cleanup: return rv; } -/* remoteDispatchDomainLookupById has to be implemented manually */ +static int +remoteDispatchDomainLookupByID( + struct qemud_server *server ATTRIBUTE_UNUSED, + struct qemud_client *client ATTRIBUTE_UNUSED, + virConnectPtr conn, + remote_message_header *hdr ATTRIBUTE_UNUSED, + remote_error *rerr, + remote_domain_lookup_by_id_args *args, + remote_domain_lookup_by_id_ret *ret) +{ + int rv = -1; + virDomainPtr dom = NULL; -/* remoteDispatchDomainLookupByName has to be implemented manually */ + if (!conn) { + virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open")); + goto cleanup; + } + + if ((dom = virDomainLookupByID(conn, args->id)) == NULL) + goto cleanup; + + make_nonnull_domain(&ret->dom, dom); + rv = 0; + +cleanup: + if (rv < 0) + remoteDispatchError(rerr); + if (dom) + virDomainFree(dom); + return rv; +} + +static int +remoteDispatchDomainLookupByName( + struct qemud_server *server ATTRIBUTE_UNUSED, + struct qemud_client *client ATTRIBUTE_UNUSED, + virConnectPtr conn, + remote_message_header *hdr ATTRIBUTE_UNUSED, + remote_error *rerr, + remote_domain_lookup_by_name_args *args, + remote_domain_lookup_by_name_ret *ret) +{ + int rv = -1; + virDomainPtr dom = NULL; + + if (!conn) { + virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open")); + goto cleanup; + } + + if ((dom = virDomainLookupByName(conn, args->name)) == NULL) + goto cleanup; -/* remoteDispatchDomainLookupByUUID has to be implemented manually */ + make_nonnull_domain(&ret->dom, dom); + rv = 0; + +cleanup: + if (rv < 0) + remoteDispatchError(rerr); + if (dom) + virDomainFree(dom); + return rv; +} + +static int +remoteDispatchDomainLookupByUUID( + struct qemud_server *server ATTRIBUTE_UNUSED, + struct qemud_client *client ATTRIBUTE_UNUSED, + virConnectPtr conn, + remote_message_header *hdr ATTRIBUTE_UNUSED, + remote_error *rerr, + remote_domain_lookup_by_uuid_args *args, + remote_domain_lookup_by_uuid_ret *ret) +{ + int rv = -1; + virDomainPtr dom = NULL; + + if (!conn) { + virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open")); + goto cleanup; + } + + if ((dom = virDomainLookupByUUID(conn, (unsigned char *) args->uuid)) == NULL) + goto cleanup; + + make_nonnull_domain(&ret->dom, dom); + rv = 0; + +cleanup: + if (rv < 0) + remoteDispatchError(rerr); + if (dom) + virDomainFree(dom); + return rv; +} static int remoteDispatchDomainManagedSave( @@ -802,9 +952,69 @@ cleanup: /* remoteDispatchDomainMemoryStats has to be implemented manually */ -/* remoteDispatchDomainMigrateFinish has to be implemented manually */ +static int +remoteDispatchDomainMigrateFinish( + struct qemud_server *server ATTRIBUTE_UNUSED, + struct qemud_client *client ATTRIBUTE_UNUSED, + virConnectPtr conn, + remote_message_header *hdr ATTRIBUTE_UNUSED, + remote_error *rerr, + remote_domain_migrate_finish_args *args, + remote_domain_migrate_finish_ret *ret) +{ + int rv = -1; + virDomainPtr ddom = NULL; + + if (!conn) { + virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open")); + goto cleanup; + } + + if ((ddom = virDomainMigrateFinish(conn, args->dname, args->cookie.cookie_val, args->cookie.cookie_len, args->uri, args->flags)) == NULL) + goto cleanup; + + make_nonnull_domain(&ret->ddom, ddom); + rv = 0; + +cleanup: + if (rv < 0) + remoteDispatchError(rerr); + if (ddom) + virDomainFree(ddom); + return rv; +} + +static int +remoteDispatchDomainMigrateFinish2( + struct qemud_server *server ATTRIBUTE_UNUSED, + struct qemud_client *client ATTRIBUTE_UNUSED, + virConnectPtr conn, + remote_message_header *hdr ATTRIBUTE_UNUSED, + remote_error *rerr, + remote_domain_migrate_finish2_args *args, + remote_domain_migrate_finish2_ret *ret) +{ + int rv = -1; + virDomainPtr ddom = NULL; + + if (!conn) { + virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open")); + goto cleanup; + } + + if ((ddom = virDomainMigrateFinish2(conn, args->dname, args->cookie.cookie_val, args->cookie.cookie_len, args->uri, args->flags, args->retcode)) == NULL) + goto cleanup; -/* remoteDispatchDomainMigrateFinish2 has to be implemented manually */ + make_nonnull_domain(&ret->ddom, ddom); + rv = 0; + +cleanup: + if (rv < 0) + remoteDispatchError(rerr); + if (ddom) + virDomainFree(ddom); + return rv; +} /* remoteDispatchDomainMigratePerform has to be implemented manually */ @@ -1300,9 +1510,81 @@ cleanup: return rv; } -/* remoteDispatchDomainSnapshotCreateXML has to be implemented manually */ +static int +remoteDispatchDomainSnapshotCreateXML( + struct qemud_server *server ATTRIBUTE_UNUSED, + struct qemud_client *client ATTRIBUTE_UNUSED, + virConnectPtr conn, + remote_message_header *hdr ATTRIBUTE_UNUSED, + remote_error *rerr, + remote_domain_snapshot_create_xml_args *args, + remote_domain_snapshot_create_xml_ret *ret) +{ + int rv = -1; + virDomainPtr dom = NULL; + virDomainSnapshotPtr snap = NULL; + + if (!conn) { + virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open")); + goto cleanup; + } + + if (!(dom = get_nonnull_domain(conn, args->dom))) + goto cleanup; + + if ((snap = virDomainSnapshotCreateXML(dom, args->xml_desc, args->flags)) == NULL) + goto cleanup; + + make_nonnull_domain_snapshot(&ret->snap, snap); + rv = 0; + +cleanup: + if (rv < 0) + remoteDispatchError(rerr); + if (dom) + virDomainFree(dom); + if (snap) + virDomainSnapshotFree(snap); + return rv; +} + +static int +remoteDispatchDomainSnapshotCurrent( + struct qemud_server *server ATTRIBUTE_UNUSED, + struct qemud_client *client ATTRIBUTE_UNUSED, + virConnectPtr conn, + remote_message_header *hdr ATTRIBUTE_UNUSED, + remote_error *rerr, + remote_domain_snapshot_current_args *args, + remote_domain_snapshot_current_ret *ret) +{ + int rv = -1; + virDomainPtr dom = NULL; + virDomainSnapshotPtr snap = NULL; + + if (!conn) { + virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open")); + goto cleanup; + } + + if (!(dom = get_nonnull_domain(conn, args->dom))) + goto cleanup; + + if ((snap = virDomainSnapshotCurrent(dom, args->flags)) == NULL) + goto cleanup; + + make_nonnull_domain_snapshot(&ret->snap, snap); + rv = 0; -/* remoteDispatchDomainSnapshotCurrent has to be implemented manually */ +cleanup: + if (rv < 0) + remoteDispatchError(rerr); + if (dom) + virDomainFree(dom); + if (snap) + virDomainSnapshotFree(snap); + return rv; +} static int remoteDispatchDomainSnapshotDelete( @@ -1388,7 +1670,43 @@ cleanup: /* remoteDispatchDomainSnapshotListNames has to be implemented manually */ -/* remoteDispatchDomainSnapshotLookupByName has to be implemented manually */ +static int +remoteDispatchDomainSnapshotLookupByName( + struct qemud_server *server ATTRIBUTE_UNUSED, + struct qemud_client *client ATTRIBUTE_UNUSED, + virConnectPtr conn, + remote_message_header *hdr ATTRIBUTE_UNUSED, + remote_error *rerr, + remote_domain_snapshot_lookup_by_name_args *args, + remote_domain_snapshot_lookup_by_name_ret *ret) +{ + int rv = -1; + virDomainPtr dom = NULL; + virDomainSnapshotPtr snap = NULL; + + if (!conn) { + virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open")); + goto cleanup; + } + + if (!(dom = get_nonnull_domain(conn, args->dom))) + goto cleanup; + + if ((snap = virDomainSnapshotLookupByName(dom, args->name, args->flags)) == NULL) + goto cleanup; + + make_nonnull_domain_snapshot(&ret->snap, snap); + rv = 0; + +cleanup: + if (rv < 0) + remoteDispatchError(rerr); + if (dom) + virDomainFree(dom); + if (snap) + virDomainSnapshotFree(snap); + return rv; +} static int remoteDispatchDomainSnapshotNum( @@ -1808,7 +2126,37 @@ cleanup: return rv; } -/* remoteDispatchInterfaceDefineXML has to be implemented manually */ +static int +remoteDispatchInterfaceDefineXML( + struct qemud_server *server ATTRIBUTE_UNUSED, + struct qemud_client *client ATTRIBUTE_UNUSED, + virConnectPtr conn, + remote_message_header *hdr ATTRIBUTE_UNUSED, + remote_error *rerr, + remote_interface_define_xml_args *args, + remote_interface_define_xml_ret *ret) +{ + int rv = -1; + virInterfacePtr iface = NULL; + + if (!conn) { + virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open")); + goto cleanup; + } + + if ((iface = virInterfaceDefineXML(conn, args->xml, args->flags)) == NULL) + goto cleanup; + + make_nonnull_interface(&ret->iface, iface); + rv = 0; + +cleanup: + if (rv < 0) + remoteDispatchError(rerr); + if (iface) + virInterfaceFree(iface); + return rv; +} static int remoteDispatchInterfaceDestroy( @@ -1916,9 +2264,69 @@ cleanup: return rv; } -/* remoteDispatchInterfaceLookupByMacString has to be implemented manually */ +static int +remoteDispatchInterfaceLookupByMACString( + struct qemud_server *server ATTRIBUTE_UNUSED, + struct qemud_client *client ATTRIBUTE_UNUSED, + virConnectPtr conn, + remote_message_header *hdr ATTRIBUTE_UNUSED, + remote_error *rerr, + remote_interface_lookup_by_mac_string_args *args, + remote_interface_lookup_by_mac_string_ret *ret) +{ + int rv = -1; + virInterfacePtr iface = NULL; -/* remoteDispatchInterfaceLookupByName has to be implemented manually */ + if (!conn) { + virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open")); + goto cleanup; + } + + if ((iface = virInterfaceLookupByMACString(conn, args->mac)) == NULL) + goto cleanup; + + make_nonnull_interface(&ret->iface, iface); + rv = 0; + +cleanup: + if (rv < 0) + remoteDispatchError(rerr); + if (iface) + virInterfaceFree(iface); + return rv; +} + +static int +remoteDispatchInterfaceLookupByName( + struct qemud_server *server ATTRIBUTE_UNUSED, + struct qemud_client *client ATTRIBUTE_UNUSED, + virConnectPtr conn, + remote_message_header *hdr ATTRIBUTE_UNUSED, + remote_error *rerr, + remote_interface_lookup_by_name_args *args, + remote_interface_lookup_by_name_ret *ret) +{ + int rv = -1; + virInterfacePtr iface = NULL; + + if (!conn) { + virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open")); + goto cleanup; + } + + if ((iface = virInterfaceLookupByName(conn, args->name)) == NULL) + goto cleanup; + + make_nonnull_interface(&ret->iface, iface); + rv = 0; + +cleanup: + if (rv < 0) + remoteDispatchError(rerr); + if (iface) + virInterfaceFree(iface); + return rv; +} static int remoteDispatchInterfaceUndefine( @@ -2038,9 +2446,69 @@ cleanup: return rv; } -/* remoteDispatchNetworkCreateXML has to be implemented manually */ +static int +remoteDispatchNetworkCreateXML( + struct qemud_server *server ATTRIBUTE_UNUSED, + struct qemud_client *client ATTRIBUTE_UNUSED, + virConnectPtr conn, + remote_message_header *hdr ATTRIBUTE_UNUSED, + remote_error *rerr, + remote_network_create_xml_args *args, + remote_network_create_xml_ret *ret) +{ + int rv = -1; + virNetworkPtr net = NULL; + + if (!conn) { + virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open")); + goto cleanup; + } -/* remoteDispatchNetworkDefineXML has to be implemented manually */ + if ((net = virNetworkCreateXML(conn, args->xml)) == NULL) + goto cleanup; + + make_nonnull_network(&ret->net, net); + rv = 0; + +cleanup: + if (rv < 0) + remoteDispatchError(rerr); + if (net) + virNetworkFree(net); + return rv; +} + +static int +remoteDispatchNetworkDefineXML( + struct qemud_server *server ATTRIBUTE_UNUSED, + struct qemud_client *client ATTRIBUTE_UNUSED, + virConnectPtr conn, + remote_message_header *hdr ATTRIBUTE_UNUSED, + remote_error *rerr, + remote_network_define_xml_args *args, + remote_network_define_xml_ret *ret) +{ + int rv = -1; + virNetworkPtr net = NULL; + + if (!conn) { + virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open")); + goto cleanup; + } + + if ((net = virNetworkDefineXML(conn, args->xml)) == NULL) + goto cleanup; + + make_nonnull_network(&ret->net, net); + rv = 0; + +cleanup: + if (rv < 0) + remoteDispatchError(rerr); + if (net) + virNetworkFree(net); + return rv; +} static int remoteDispatchNetworkDestroy( @@ -2256,9 +2724,69 @@ cleanup: return rv; } -/* remoteDispatchNetworkLookupByName has to be implemented manually */ +static int +remoteDispatchNetworkLookupByName( + struct qemud_server *server ATTRIBUTE_UNUSED, + struct qemud_client *client ATTRIBUTE_UNUSED, + virConnectPtr conn, + remote_message_header *hdr ATTRIBUTE_UNUSED, + remote_error *rerr, + remote_network_lookup_by_name_args *args, + remote_network_lookup_by_name_ret *ret) +{ + int rv = -1; + virNetworkPtr net = NULL; + + if (!conn) { + virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open")); + goto cleanup; + } + + if ((net = virNetworkLookupByName(conn, args->name)) == NULL) + goto cleanup; + + make_nonnull_network(&ret->net, net); + rv = 0; + +cleanup: + if (rv < 0) + remoteDispatchError(rerr); + if (net) + virNetworkFree(net); + return rv; +} + +static int +remoteDispatchNetworkLookupByUUID( + struct qemud_server *server ATTRIBUTE_UNUSED, + struct qemud_client *client ATTRIBUTE_UNUSED, + virConnectPtr conn, + remote_message_header *hdr ATTRIBUTE_UNUSED, + remote_error *rerr, + remote_network_lookup_by_uuid_args *args, + remote_network_lookup_by_uuid_ret *ret) +{ + int rv = -1; + virNetworkPtr net = NULL; + + if (!conn) { + virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open")); + goto cleanup; + } + + if ((net = virNetworkLookupByUUID(conn, (unsigned char *) args->uuid)) == NULL) + goto cleanup; + + make_nonnull_network(&ret->net, net); + rv = 0; -/* remoteDispatchNetworkLookupByUUID has to be implemented manually */ +cleanup: + if (rv < 0) + remoteDispatchError(rerr); + if (net) + virNetworkFree(net); + return rv; +} static int remoteDispatchNetworkSetAutostart( @@ -2328,7 +2856,37 @@ cleanup: return rv; } -/* remoteDispatchNodeDeviceCreateXML has to be implemented manually */ +static int +remoteDispatchNodeDeviceCreateXML( + struct qemud_server *server ATTRIBUTE_UNUSED, + struct qemud_client *client ATTRIBUTE_UNUSED, + virConnectPtr conn, + remote_message_header *hdr ATTRIBUTE_UNUSED, + remote_error *rerr, + remote_node_device_create_xml_args *args, + remote_node_device_create_xml_ret *ret) +{ + int rv = -1; + virNodeDevicePtr dev = NULL; + + if (!conn) { + virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open")); + goto cleanup; + } + + if ((dev = virNodeDeviceCreateXML(conn, args->xml_desc, args->flags)) == NULL) + goto cleanup; + + make_nonnull_node_device(&ret->dev, dev); + rv = 0; + +cleanup: + if (rv < 0) + remoteDispatchError(rerr); + if (dev) + virNodeDeviceFree(dev); + return rv; +} static int remoteDispatchNodeDeviceDestroy( @@ -2438,7 +2996,37 @@ cleanup: /* remoteDispatchNodeDeviceListCaps has to be implemented manually */ -/* remoteDispatchNodeDeviceLookupByName has to be implemented manually */ +static int +remoteDispatchNodeDeviceLookupByName( + struct qemud_server *server ATTRIBUTE_UNUSED, + struct qemud_client *client ATTRIBUTE_UNUSED, + virConnectPtr conn, + remote_message_header *hdr ATTRIBUTE_UNUSED, + remote_error *rerr, + remote_node_device_lookup_by_name_args *args, + remote_node_device_lookup_by_name_ret *ret) +{ + int rv = -1; + virNodeDevicePtr dev = NULL; + + if (!conn) { + virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open")); + goto cleanup; + } + + if ((dev = virNodeDeviceLookupByName(conn, args->name)) == NULL) + goto cleanup; + + make_nonnull_node_device(&ret->dev, dev); + rv = 0; + +cleanup: + if (rv < 0) + remoteDispatchError(rerr); + if (dev) + virNodeDeviceFree(dev); + return rv; +} static int remoteDispatchNodeDeviceNumOfCaps( @@ -2546,7 +3134,35 @@ cleanup: /* remoteDispatchNodeGetCellsFreeMemory has to be implemented manually */ -/* remoteDispatchNodeGetFreeMemory has to be implemented manually */ +static int +remoteDispatchNodeGetFreeMemory( + struct qemud_server *server ATTRIBUTE_UNUSED, + struct qemud_client *client ATTRIBUTE_UNUSED, + virConnectPtr conn, + remote_message_header *hdr ATTRIBUTE_UNUSED, + remote_error *rerr, + void *args ATTRIBUTE_UNUSED, + remote_node_get_free_memory_ret *ret) +{ + int rv = -1; + unsigned long freeMem; + + if (!conn) { + virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open")); + goto cleanup; + } + + if ((freeMem = virNodeGetFreeMemory(conn)) == 0) + goto cleanup; + + ret->freeMem = freeMem; + rv = 0; + +cleanup: + if (rv < 0) + remoteDispatchError(rerr); + return rv; +} /* remoteDispatchNodeGetInfo has to be implemented manually */ @@ -2856,7 +3472,37 @@ cleanup: return rv; } -/* remoteDispatchNWFilterDefineXML has to be implemented manually */ +static int +remoteDispatchNWFilterDefineXML( + struct qemud_server *server ATTRIBUTE_UNUSED, + struct qemud_client *client ATTRIBUTE_UNUSED, + virConnectPtr conn, + remote_message_header *hdr ATTRIBUTE_UNUSED, + remote_error *rerr, + remote_nwfilter_define_xml_args *args, + remote_nwfilter_define_xml_ret *ret) +{ + int rv = -1; + virNWFilterPtr nwfilter = NULL; + + if (!conn) { + virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open")); + goto cleanup; + } + + if ((nwfilter = virNWFilterDefineXML(conn, args->xml)) == NULL) + goto cleanup; + + make_nonnull_nwfilter(&ret->nwfilter, nwfilter); + rv = 0; + +cleanup: + if (rv < 0) + remoteDispatchError(rerr); + if (nwfilter) + virNWFilterFree(nwfilter); + return rv; +} static int remoteDispatchNWFilterGetXMLDesc( @@ -2894,9 +3540,69 @@ cleanup: return rv; } -/* remoteDispatchNWFilterLookupByName has to be implemented manually */ +static int +remoteDispatchNWFilterLookupByName( + struct qemud_server *server ATTRIBUTE_UNUSED, + struct qemud_client *client ATTRIBUTE_UNUSED, + virConnectPtr conn, + remote_message_header *hdr ATTRIBUTE_UNUSED, + remote_error *rerr, + remote_nwfilter_lookup_by_name_args *args, + remote_nwfilter_lookup_by_name_ret *ret) +{ + int rv = -1; + virNWFilterPtr nwfilter = NULL; + + if (!conn) { + virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open")); + goto cleanup; + } + + if ((nwfilter = virNWFilterLookupByName(conn, args->name)) == NULL) + goto cleanup; + + make_nonnull_nwfilter(&ret->nwfilter, nwfilter); + rv = 0; + +cleanup: + if (rv < 0) + remoteDispatchError(rerr); + if (nwfilter) + virNWFilterFree(nwfilter); + return rv; +} + +static int +remoteDispatchNWFilterLookupByUUID( + struct qemud_server *server ATTRIBUTE_UNUSED, + struct qemud_client *client ATTRIBUTE_UNUSED, + virConnectPtr conn, + remote_message_header *hdr ATTRIBUTE_UNUSED, + remote_error *rerr, + remote_nwfilter_lookup_by_uuid_args *args, + remote_nwfilter_lookup_by_uuid_ret *ret) +{ + int rv = -1; + virNWFilterPtr nwfilter = NULL; + + if (!conn) { + virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open")); + goto cleanup; + } + + if ((nwfilter = virNWFilterLookupByUUID(conn, (unsigned char *) args->uuid)) == NULL) + goto cleanup; -/* remoteDispatchNWFilterLookupByUUID has to be implemented manually */ + make_nonnull_nwfilter(&ret->nwfilter, nwfilter); + rv = 0; + +cleanup: + if (rv < 0) + remoteDispatchError(rerr); + if (nwfilter) + virNWFilterFree(nwfilter); + return rv; +} static int remoteDispatchNWFilterUndefine( @@ -2934,7 +3640,37 @@ cleanup: /* remoteDispatchOpen has to be implemented manually */ -/* remoteDispatchSecretDefineXML has to be implemented manually */ +static int +remoteDispatchSecretDefineXML( + struct qemud_server *server ATTRIBUTE_UNUSED, + struct qemud_client *client ATTRIBUTE_UNUSED, + virConnectPtr conn, + remote_message_header *hdr ATTRIBUTE_UNUSED, + remote_error *rerr, + remote_secret_define_xml_args *args, + remote_secret_define_xml_ret *ret) +{ + int rv = -1; + virSecretPtr secret = NULL; + + if (!conn) { + virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open")); + goto cleanup; + } + + if ((secret = virSecretDefineXML(conn, args->xml, args->flags)) == NULL) + goto cleanup; + + make_nonnull_secret(&ret->secret, secret); + rv = 0; + +cleanup: + if (rv < 0) + remoteDispatchError(rerr); + if (secret) + virSecretFree(secret); + return rv; +} /* remoteDispatchSecretGetValue has to be implemented manually */ @@ -2974,9 +3710,69 @@ cleanup: return rv; } -/* remoteDispatchSecretLookupByUsage has to be implemented manually */ +static int +remoteDispatchSecretLookupByUsage( + struct qemud_server *server ATTRIBUTE_UNUSED, + struct qemud_client *client ATTRIBUTE_UNUSED, + virConnectPtr conn, + remote_message_header *hdr ATTRIBUTE_UNUSED, + remote_error *rerr, + remote_secret_lookup_by_usage_args *args, + remote_secret_lookup_by_usage_ret *ret) +{ + int rv = -1; + virSecretPtr secret = NULL; + + if (!conn) { + virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open")); + goto cleanup; + } + + if ((secret = virSecretLookupByUsage(conn, args->usageType, args->usageID)) == NULL) + goto cleanup; + + make_nonnull_secret(&ret->secret, secret); + rv = 0; + +cleanup: + if (rv < 0) + remoteDispatchError(rerr); + if (secret) + virSecretFree(secret); + return rv; +} + +static int +remoteDispatchSecretLookupByUUID( + struct qemud_server *server ATTRIBUTE_UNUSED, + struct qemud_client *client ATTRIBUTE_UNUSED, + virConnectPtr conn, + remote_message_header *hdr ATTRIBUTE_UNUSED, + remote_error *rerr, + remote_secret_lookup_by_uuid_args *args, + remote_secret_lookup_by_uuid_ret *ret) +{ + int rv = -1; + virSecretPtr secret = NULL; + + if (!conn) { + virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open")); + goto cleanup; + } + + if ((secret = virSecretLookupByUUID(conn, (unsigned char *) args->uuid)) == NULL) + goto cleanup; -/* remoteDispatchSecretLookupByUUID has to be implemented manually */ + make_nonnull_secret(&ret->secret, secret); + rv = 0; + +cleanup: + if (rv < 0) + remoteDispatchError(rerr); + if (secret) + virSecretFree(secret); + return rv; +} static int remoteDispatchSecretSetValue( @@ -3114,9 +3910,69 @@ cleanup: return rv; } -/* remoteDispatchStoragePoolCreateXML has to be implemented manually */ +static int +remoteDispatchStoragePoolCreateXML( + struct qemud_server *server ATTRIBUTE_UNUSED, + struct qemud_client *client ATTRIBUTE_UNUSED, + virConnectPtr conn, + remote_message_header *hdr ATTRIBUTE_UNUSED, + remote_error *rerr, + remote_storage_pool_create_xml_args *args, + remote_storage_pool_create_xml_ret *ret) +{ + int rv = -1; + virStoragePoolPtr pool = NULL; + + if (!conn) { + virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open")); + goto cleanup; + } + + if ((pool = virStoragePoolCreateXML(conn, args->xml, args->flags)) == NULL) + goto cleanup; + + make_nonnull_storage_pool(&ret->pool, pool); + rv = 0; -/* remoteDispatchStoragePoolDefineXML has to be implemented manually */ +cleanup: + if (rv < 0) + remoteDispatchError(rerr); + if (pool) + virStoragePoolFree(pool); + return rv; +} + +static int +remoteDispatchStoragePoolDefineXML( + struct qemud_server *server ATTRIBUTE_UNUSED, + struct qemud_client *client ATTRIBUTE_UNUSED, + virConnectPtr conn, + remote_message_header *hdr ATTRIBUTE_UNUSED, + remote_error *rerr, + remote_storage_pool_define_xml_args *args, + remote_storage_pool_define_xml_ret *ret) +{ + int rv = -1; + virStoragePoolPtr pool = NULL; + + if (!conn) { + virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open")); + goto cleanup; + } + + if ((pool = virStoragePoolDefineXML(conn, args->xml, args->flags)) == NULL) + goto cleanup; + + make_nonnull_storage_pool(&ret->pool, pool); + rv = 0; + +cleanup: + if (rv < 0) + remoteDispatchError(rerr); + if (pool) + virStoragePoolFree(pool); + return rv; +} static int remoteDispatchStoragePoolDelete( @@ -3334,11 +4190,107 @@ cleanup: /* remoteDispatchStoragePoolListVolumes has to be implemented manually */ -/* remoteDispatchStoragePoolLookupByName has to be implemented manually */ +static int +remoteDispatchStoragePoolLookupByName( + struct qemud_server *server ATTRIBUTE_UNUSED, + struct qemud_client *client ATTRIBUTE_UNUSED, + virConnectPtr conn, + remote_message_header *hdr ATTRIBUTE_UNUSED, + remote_error *rerr, + remote_storage_pool_lookup_by_name_args *args, + remote_storage_pool_lookup_by_name_ret *ret) +{ + int rv = -1; + virStoragePoolPtr pool = NULL; + + if (!conn) { + virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open")); + goto cleanup; + } + + if ((pool = virStoragePoolLookupByName(conn, args->name)) == NULL) + goto cleanup; + + make_nonnull_storage_pool(&ret->pool, pool); + rv = 0; + +cleanup: + if (rv < 0) + remoteDispatchError(rerr); + if (pool) + virStoragePoolFree(pool); + return rv; +} + +static int +remoteDispatchStoragePoolLookupByUUID( + struct qemud_server *server ATTRIBUTE_UNUSED, + struct qemud_client *client ATTRIBUTE_UNUSED, + virConnectPtr conn, + remote_message_header *hdr ATTRIBUTE_UNUSED, + remote_error *rerr, + remote_storage_pool_lookup_by_uuid_args *args, + remote_storage_pool_lookup_by_uuid_ret *ret) +{ + int rv = -1; + virStoragePoolPtr pool = NULL; + + if (!conn) { + virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open")); + goto cleanup; + } + + if ((pool = virStoragePoolLookupByUUID(conn, (unsigned char *) args->uuid)) == NULL) + goto cleanup; + + make_nonnull_storage_pool(&ret->pool, pool); + rv = 0; + +cleanup: + if (rv < 0) + remoteDispatchError(rerr); + if (pool) + virStoragePoolFree(pool); + return rv; +} + +static int +remoteDispatchStoragePoolLookupByVolume( + struct qemud_server *server ATTRIBUTE_UNUSED, + struct qemud_client *client ATTRIBUTE_UNUSED, + virConnectPtr conn, + remote_message_header *hdr ATTRIBUTE_UNUSED, + remote_error *rerr, + remote_storage_pool_lookup_by_volume_args *args, + remote_storage_pool_lookup_by_volume_ret *ret) +{ + int rv = -1; + virStorageVolPtr vol = NULL; + virStoragePoolPtr pool = NULL; + + if (!conn) { + virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open")); + goto cleanup; + } -/* remoteDispatchStoragePoolLookupByUUID has to be implemented manually */ + if (!(vol = get_nonnull_storage_vol(conn, args->vol))) + goto cleanup; + + if ((pool = virStoragePoolLookupByVolume(vol)) == NULL) + goto cleanup; -/* remoteDispatchStoragePoolLookupByVolume has to be implemented manually */ + make_nonnull_storage_pool(&ret->pool, pool); + rv = 0; + +cleanup: + if (rv < 0) + remoteDispatchError(rerr); + if (vol) + virStorageVolFree(vol); + if (pool) + virStoragePoolFree(pool); + return rv; +} static int remoteDispatchStoragePoolNumOfVolumes( @@ -3478,9 +4430,87 @@ cleanup: return rv; } -/* remoteDispatchStorageVolCreateXML has to be implemented manually */ +static int +remoteDispatchStorageVolCreateXML( + struct qemud_server *server ATTRIBUTE_UNUSED, + struct qemud_client *client ATTRIBUTE_UNUSED, + virConnectPtr conn, + remote_message_header *hdr ATTRIBUTE_UNUSED, + remote_error *rerr, + remote_storage_vol_create_xml_args *args, + remote_storage_vol_create_xml_ret *ret) +{ + int rv = -1; + virStoragePoolPtr pool = NULL; + virStorageVolPtr vol = NULL; + + if (!conn) { + virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open")); + goto cleanup; + } + + if (!(pool = get_nonnull_storage_pool(conn, args->pool))) + goto cleanup; + + if ((vol = virStorageVolCreateXML(pool, args->xml, args->flags)) == NULL) + goto cleanup; + + make_nonnull_storage_vol(&ret->vol, vol); + rv = 0; + +cleanup: + if (rv < 0) + remoteDispatchError(rerr); + if (pool) + virStoragePoolFree(pool); + if (vol) + virStorageVolFree(vol); + return rv; +} + +static int +remoteDispatchStorageVolCreateXMLFrom( + struct qemud_server *server ATTRIBUTE_UNUSED, + struct qemud_client *client ATTRIBUTE_UNUSED, + virConnectPtr conn, + remote_message_header *hdr ATTRIBUTE_UNUSED, + remote_error *rerr, + remote_storage_vol_create_xml_from_args *args, + remote_storage_vol_create_xml_from_ret *ret) +{ + int rv = -1; + virStoragePoolPtr pool = NULL; + virStorageVolPtr clonevol = NULL; + virStorageVolPtr vol = NULL; + + if (!conn) { + virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open")); + goto cleanup; + } + + if (!(pool = get_nonnull_storage_pool(conn, args->pool))) + goto cleanup; + + if (!(clonevol = get_nonnull_storage_vol(conn, args->clonevol))) + goto cleanup; -/* remoteDispatchStorageVolCreateXMLFrom has to be implemented manually */ + if ((vol = virStorageVolCreateXMLFrom(pool, args->xml, clonevol, args->flags)) == NULL) + goto cleanup; + + make_nonnull_storage_vol(&ret->vol, vol); + rv = 0; + +cleanup: + if (rv < 0) + remoteDispatchError(rerr); + if (pool) + virStoragePoolFree(pool); + if (clonevol) + virStorageVolFree(clonevol); + if (vol) + virStorageVolFree(vol); + return rv; +} static int remoteDispatchStorageVolDelete( @@ -3592,11 +4622,107 @@ cleanup: return rv; } -/* remoteDispatchStorageVolLookupByKey has to be implemented manually */ +static int +remoteDispatchStorageVolLookupByKey( + struct qemud_server *server ATTRIBUTE_UNUSED, + struct qemud_client *client ATTRIBUTE_UNUSED, + virConnectPtr conn, + remote_message_header *hdr ATTRIBUTE_UNUSED, + remote_error *rerr, + remote_storage_vol_lookup_by_key_args *args, + remote_storage_vol_lookup_by_key_ret *ret) +{ + int rv = -1; + virStorageVolPtr vol = NULL; + + if (!conn) { + virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open")); + goto cleanup; + } + + if ((vol = virStorageVolLookupByKey(conn, args->key)) == NULL) + goto cleanup; + + make_nonnull_storage_vol(&ret->vol, vol); + rv = 0; + +cleanup: + if (rv < 0) + remoteDispatchError(rerr); + if (vol) + virStorageVolFree(vol); + return rv; +} + +static int +remoteDispatchStorageVolLookupByName( + struct qemud_server *server ATTRIBUTE_UNUSED, + struct qemud_client *client ATTRIBUTE_UNUSED, + virConnectPtr conn, + remote_message_header *hdr ATTRIBUTE_UNUSED, + remote_error *rerr, + remote_storage_vol_lookup_by_name_args *args, + remote_storage_vol_lookup_by_name_ret *ret) +{ + int rv = -1; + virStoragePoolPtr pool = NULL; + virStorageVolPtr vol = NULL; + + if (!conn) { + virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open")); + goto cleanup; + } + + if (!(pool = get_nonnull_storage_pool(conn, args->pool))) + goto cleanup; + + if ((vol = virStorageVolLookupByName(pool, args->name)) == NULL) + goto cleanup; + + make_nonnull_storage_vol(&ret->vol, vol); + rv = 0; + +cleanup: + if (rv < 0) + remoteDispatchError(rerr); + if (pool) + virStoragePoolFree(pool); + if (vol) + virStorageVolFree(vol); + return rv; +} + +static int +remoteDispatchStorageVolLookupByPath( + struct qemud_server *server ATTRIBUTE_UNUSED, + struct qemud_client *client ATTRIBUTE_UNUSED, + virConnectPtr conn, + remote_message_header *hdr ATTRIBUTE_UNUSED, + remote_error *rerr, + remote_storage_vol_lookup_by_path_args *args, + remote_storage_vol_lookup_by_path_ret *ret) +{ + int rv = -1; + virStorageVolPtr vol = NULL; + + if (!conn) { + virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open")); + goto cleanup; + } + + if ((vol = virStorageVolLookupByPath(conn, args->path)) == NULL) + goto cleanup; -/* remoteDispatchStorageVolLookupByName has to be implemented manually */ + make_nonnull_storage_vol(&ret->vol, vol); + rv = 0; -/* remoteDispatchStorageVolLookupByPath has to be implemented manually */ +cleanup: + if (rv < 0) + remoteDispatchError(rerr); + if (vol) + virStorageVolFree(vol); + return rv; +} /* remoteDispatchStorageVolUpload has to be implemented manually */ diff --git a/daemon/remote_dispatch_prototypes.h b/daemon/remote_dispatch_prototypes.h index dff84d7..1e3be48 100644 --- a/daemon/remote_dispatch_prototypes.h +++ b/daemon/remote_dispatch_prototypes.h @@ -370,7 +370,7 @@ static int remoteDispatchDomainIsUpdated( remote_error *rerr, remote_domain_is_updated_args *args, remote_domain_is_updated_ret *ret); -static int remoteDispatchDomainLookupById( +static int remoteDispatchDomainLookupByID( struct qemud_server *server, struct qemud_client *client, virConnectPtr conn, @@ -834,7 +834,7 @@ static int remoteDispatchInterfaceIsActive( remote_error *rerr, remote_interface_is_active_args *args, remote_interface_is_active_ret *ret); -static int remoteDispatchInterfaceLookupByMacString( +static int remoteDispatchInterfaceLookupByMACString( struct qemud_server *server, struct qemud_client *client, virConnectPtr conn, diff --git a/daemon/remote_dispatch_table.h b/daemon/remote_dispatch_table.h index 627331e..357d1de 100644 --- a/daemon/remote_dispatch_table.h +++ b/daemon/remote_dispatch_table.h @@ -112,8 +112,8 @@ .args_filter = (xdrproc_t) xdr_remote_list_defined_domains_args, .ret_filter = (xdrproc_t) xdr_remote_list_defined_domains_ret, }, -{ /* DomainLookupById => 22 */ - .fn = (dispatch_fn) remoteDispatchDomainLookupById, +{ /* DomainLookupByID => 22 */ + .fn = (dispatch_fn) remoteDispatchDomainLookupByID, .args_filter = (xdrproc_t) xdr_remote_domain_lookup_by_id_args, .ret_filter = (xdrproc_t) xdr_remote_domain_lookup_by_id_ret, }, @@ -647,8 +647,8 @@ .args_filter = (xdrproc_t) xdr_remote_interface_lookup_by_name_args, .ret_filter = (xdrproc_t) xdr_remote_interface_lookup_by_name_ret, }, -{ /* InterfaceLookupByMacString => 129 */ - .fn = (dispatch_fn) remoteDispatchInterfaceLookupByMacString, +{ /* InterfaceLookupByMACString => 129 */ + .fn = (dispatch_fn) remoteDispatchInterfaceLookupByMACString, .args_filter = (xdrproc_t) xdr_remote_interface_lookup_by_mac_string_args, .ret_filter = (xdrproc_t) xdr_remote_interface_lookup_by_mac_string_ret, }, diff --git a/daemon/remote_generator.pl b/daemon/remote_generator.pl index 0901649..1b83d52 100755 --- a/daemon/remote_generator.pl +++ b/daemon/remote_generator.pl @@ -33,7 +33,8 @@ sub name_to_ProcName { my @elems = split /_/, $name; @elems = map ucfirst, @elems; @elems = map { $_ =~ s/Nwfilter/NWFilter/; $_ =~ s/Xml/XML/; - $_ =~ s/Uri/URI/; $_ =~ s/Uuid/UUID/; $_ } @elems; + $_ =~ s/Uri/URI/; $_ =~ s/Uuid/UUID/; $_ =~ s/Id/ID/; + $_ =~ s/Mac/MAC/; $_ } @elems; join "", @elems } @@ -262,8 +263,6 @@ elsif ($opt_b) { "DomainBlockPeek", "DomainBlockStats", "DomainCreateWithFlags", - "DomainCreateXML", - "DomainDefineXML", "DomainEventsDeregister", "DomainEventsRegister", "DomainGetBlkioParameters", @@ -276,25 +275,14 @@ elsif ($opt_b) { "DomainGetSecurityLabel", "DomainGetVcpus", "DomainInterfaceStats", - "DomainLookupById", - "DomainLookupByName", - "DomainLookupByUUID", "DomainMemoryPeek", "DomainMemoryStats", - "DomainMigrateFinish", - "DomainMigrateFinish2", "DomainMigratePrepare", "DomainMigratePrepare2", - "DomainSnapshotCreateXML", - "DomainSnapshotCurrent", "DomainSnapshotListNames", - "DomainSnapshotLookupByName", "FindStoragePoolSources", "GetMaxVcpus", "GetType", - "InterfaceLookupByMacString", - "InterfaceLookupByName", - "InterfaceDefineXML", "ListDefinedDomains", "ListDefinedInterfaces", "ListDefinedNetworks", @@ -305,40 +293,17 @@ elsif ($opt_b) { "ListNWFilters", "ListSecrets", "ListStoragePools", - "NetworkLookupByName", - "NetworkLookupByUUID", - "NodeDeviceCreateXML", - "NetworkCreateXML", "NodeDeviceGetParent", "NodeDeviceListCaps", - "NodeDeviceLookupByName", "NodeGetCellsFreeMemory", - "NodeGetFreeMemory", "NodeGetInfo", "NodeGetSecurityModel", - "NetworkDefineXML", "NodeListDevices", "NodeNumOfDevices", - "NWFilterLookupByName", - "NWFilterLookupByUUID", - "SecretDefineXML", "SecretGetValue", - "NWFilterDefineXML", - "SecretLookupByUsage", - "SecretLookupByUUID", - "StoragePoolCreateXML", - "StoragePoolDefineXML", "StoragePoolGetInfo", "StoragePoolListVolumes", - "StoragePoolLookupByName", - "StoragePoolLookupByUUID", - "StoragePoolLookupByVolume", - "StorageVolCreateXML", - "StorageVolCreateXMLFrom", - "StorageVolGetInfo", - "StorageVolLookupByKey", - "StorageVolLookupByName", - "StorageVolLookupByPath"); + "StorageVolGetInfo"); } elsif ($structprefix eq "qemu") { @ungeneratable = ("MonitorCommand"); } @@ -350,7 +315,6 @@ elsif ($opt_b) { # skip things which are REMOTE_MESSAGE next if $calls{$_}->{msg}; - # FIXME: skip functions with explicit return value for now if (exists($ug{$calls{$_}->{ProcName}})) { print "/* ${structprefix}Dispatch$calls{$_}->{ProcName} has to " . "be implemented manually */\n\n"; @@ -390,7 +354,9 @@ elsif ($opt_b) { if ($calls{$_}->{args} ne "void") { # node device is special, as it's identified by name - if ($calls{$_}->{args} =~ m/^remote_node_device/) { + if ($calls{$_}->{args} =~ m/^remote_node_device_/ and + !($calls{$_}->{args} =~ m/^remote_node_device_lookup_by_name_/) and + !($calls{$_}->{args} =~ m/^remote_node_device_create_xml_/)) { $has_node_device = 1; push(@vars_list, "virNodeDevicePtr dev = NULL"); push(@getters_list, @@ -406,69 +372,69 @@ elsif ($opt_b) { if ($args_member =~ m/^remote_nonnull_string name;/ and $has_node_device) { # ignore the name arg for node devices next - } elsif ($args_member =~ m/^remote_nonnull_domain /) { - push(@vars_list, "virDomainPtr dom = NULL"); + } elsif ($args_member =~ m/^remote_nonnull_domain (\S+);/) { + push(@vars_list, "virDomainPtr $1 = NULL"); push(@getters_list, - " if (!(dom = get_nonnull_domain(conn, args->dom)))\n" . + " if (!($1 = get_nonnull_domain(conn, args->$1)))\n" . " goto cleanup;\n"); - push(@args_list, "dom"); + push(@args_list, "$1"); push(@free_list, - " if (dom)\n" . - " virDomainFree(dom);"); - } elsif ($args_member =~ m/^remote_nonnull_network /) { - push(@vars_list, "virNetworkPtr net = NULL"); + " if ($1)\n" . + " virDomainFree($1);"); + } elsif ($args_member =~ m/^remote_nonnull_network (\S+);/) { + push(@vars_list, "virNetworkPtr $1 = NULL"); push(@getters_list, - " if (!(net = get_nonnull_network(conn, args->net)))\n" . + " if (!($1 = get_nonnull_network(conn, args->$1)))\n" . " goto cleanup;\n"); - push(@args_list, "net"); + push(@args_list, "$1"); push(@free_list, - " if (net)\n" . - " virNetworkFree(net);"); - } elsif ($args_member =~ m/^remote_nonnull_storage_pool /) { - push(@vars_list, "virStoragePoolPtr pool = NULL"); + " if ($1)\n" . + " virNetworkFree($1);"); + } elsif ($args_member =~ m/^remote_nonnull_storage_pool (\S+);/) { + push(@vars_list, "virStoragePoolPtr $1 = NULL"); push(@getters_list, - " if (!(pool = get_nonnull_storage_pool(conn, args->pool)))\n" . + " if (!($1 = get_nonnull_storage_pool(conn, args->$1)))\n" . " goto cleanup;\n"); - push(@args_list, "pool"); + push(@args_list, "$1"); push(@free_list, - " if (pool)\n" . - " virStoragePoolFree(pool);"); - } elsif ($args_member =~ m/^remote_nonnull_storage_vol /) { - push(@vars_list, "virStorageVolPtr vol = NULL"); + " if ($1)\n" . + " virStoragePoolFree($1);"); + } elsif ($args_member =~ m/^remote_nonnull_storage_vol (\S+);/) { + push(@vars_list, "virStorageVolPtr $1 = NULL"); push(@getters_list, - " if (!(vol = get_nonnull_storage_vol(conn, args->vol)))\n" . + " if (!($1 = get_nonnull_storage_vol(conn, args->$1)))\n" . " goto cleanup;\n"); - push(@args_list, "vol"); + push(@args_list, "$1"); push(@free_list, - " if (vol)\n" . - " virStorageVolFree(vol);"); - } elsif ($args_member =~ m/^remote_nonnull_interface /) { - push(@vars_list, "virInterfacePtr iface = NULL"); + " if ($1)\n" . + " virStorageVolFree($1);"); + } elsif ($args_member =~ m/^remote_nonnull_interface (\S+);/) { + push(@vars_list, "virInterfacePtr $1 = NULL"); push(@getters_list, - " if (!(iface = get_nonnull_interface(conn, args->iface)))\n" . + " if (!($1 = get_nonnull_interface(conn, args->$1)))\n" . " goto cleanup;\n"); - push(@args_list, "iface"); + push(@args_list, "$1"); push(@free_list, - " if (iface)\n" . - " virInterfaceFree(iface);"); - } elsif ($args_member =~ m/^remote_nonnull_secret /) { - push(@vars_list, "virSecretPtr secret = NULL"); + " if ($1)\n" . + " virInterfaceFree($1);"); + } elsif ($args_member =~ m/^remote_nonnull_secret (\S+);/) { + push(@vars_list, "virSecretPtr $1 = NULL"); push(@getters_list, - " if (!(secret = get_nonnull_secret(conn, args->secret)))\n" . + " if (!($1 = get_nonnull_secret(conn, args->$1)))\n" . " goto cleanup;\n"); - push(@args_list, "secret"); + push(@args_list, "$1"); push(@free_list, - " if (secret)\n" . - " virSecretFree(secret);"); - } elsif ($args_member =~ m/^remote_nonnull_nwfilter /) { - push(@vars_list, "virNWFilterPtr nwfilter = NULL"); + " if ($1)\n" . + " virSecretFree($1);"); + } elsif ($args_member =~ m/^remote_nonnull_nwfilter (\S+);/) { + push(@vars_list, "virNWFilterPtr $1 = NULL"); push(@getters_list, - " if (!(nwfilter = get_nonnull_nwfilter(conn, args->nwfilter)))\n" . + " if (!($1 = get_nonnull_nwfilter(conn, args->$1)))\n" . " goto cleanup;\n"); - push(@args_list, "nwfilter"); + push(@args_list, "$1"); push(@free_list, - " if (nwfilter)\n" . - " virNWFilterFree(nwfilter);"); + " if ($1)\n" . + " virNWFilterFree($1);"); } elsif ($args_member =~ m/^remote_nonnull_domain_snapshot /) { push(@vars_list, "virDomainPtr dom = NULL"); push(@vars_list, "virDomainSnapshotPtr snapshot = NULL"); @@ -496,12 +462,16 @@ elsif ($opt_b) { } push(@args_list, "args->$1.$1_len"); - } elsif ($args_member =~ m/.* (\S+);/) { + } elsif ($args_member =~ m/(\S+) (\S+);/) { if (! @args_list) { push(@args_list, "conn"); } - push(@args_list, "args->$1"); + if ($1 eq "remote_uuid") { + push(@args_list, "(unsigned char *) args->$2"); + } else { + push(@args_list, "args->$2"); + } } } } @@ -521,6 +491,87 @@ elsif ($opt_b) { $single_ret_var = $1; $single_ret_by_ref = 0; $single_ret_check = " == NULL"; + } elsif ($ret_member =~ m/remote_nonnull_domain (\S+);/) { + push(@vars_list, "virDomainPtr $1 = NULL"); + push(@ret_list, "make_nonnull_domain(&ret->$1, $1);"); + push(@free_list, + " if ($1)\n" . + " virDomainFree($1);"); + $single_ret_var = $1; + $single_ret_by_ref = 0; + $single_ret_check = " == NULL"; + } elsif ($ret_member =~ m/remote_nonnull_network (\S+);/) { + push(@vars_list, "virNetworkPtr $1 = NULL"); + push(@ret_list, "make_nonnull_network(&ret->$1, $1);"); + push(@free_list, + " if ($1)\n" . + " virNetworkFree($1);"); + $single_ret_var = $1; + $single_ret_by_ref = 0; + $single_ret_check = " == NULL"; + } elsif ($ret_member =~ m/remote_nonnull_storage_pool (\S+);/) { + push(@vars_list, "virStoragePoolPtr $1 = NULL"); + push(@ret_list, "make_nonnull_storage_pool(&ret->$1, $1);"); + push(@free_list, + " if ($1)\n" . + " virStoragePoolFree($1);"); + $single_ret_var = $1; + $single_ret_by_ref = 0; + $single_ret_check = " == NULL"; + } elsif ($ret_member =~ m/remote_nonnull_storage_vol (\S+);/) { + push(@vars_list, "virStorageVolPtr $1 = NULL"); + push(@ret_list, "make_nonnull_storage_vol(&ret->$1, $1);"); + push(@free_list, + " if ($1)\n" . + " virStorageVolFree($1);"); + $single_ret_var = $1; + $single_ret_by_ref = 0; + $single_ret_check = " == NULL"; + } elsif ($ret_member =~ m/remote_nonnull_interface (\S+);/) { + push(@vars_list, "virInterfacePtr $1 = NULL"); + push(@ret_list, "make_nonnull_interface(&ret->$1, $1);"); + push(@free_list, + " if ($1)\n" . + " virInterfaceFree($1);"); + $single_ret_var = $1; + $single_ret_by_ref = 0; + $single_ret_check = " == NULL"; + } elsif ($ret_member =~ m/remote_nonnull_node_device (\S+);/) { + push(@vars_list, "virNodeDevicePtr $1 = NULL"); + push(@ret_list, "make_nonnull_node_device(&ret->$1, $1);"); + push(@free_list, + " if ($1)\n" . + " virNodeDeviceFree($1);"); + $single_ret_var = $1; + $single_ret_by_ref = 0; + $single_ret_check = " == NULL"; + } elsif ($ret_member =~ m/remote_nonnull_secret (\S+);/) { + push(@vars_list, "virSecretPtr $1 = NULL"); + push(@ret_list, "make_nonnull_secret(&ret->$1, $1);"); + push(@free_list, + " if ($1)\n" . + " virSecretFree($1);"); + $single_ret_var = $1; + $single_ret_by_ref = 0; + $single_ret_check = " == NULL"; + } elsif ($ret_member =~ m/remote_nonnull_nwfilter (\S+);/) { + push(@vars_list, "virNWFilterPtr $1 = NULL"); + push(@ret_list, "make_nonnull_nwfilter(&ret->$1, $1);"); + push(@free_list, + " if ($1)\n" . + " virNWFilterFree($1);"); + $single_ret_var = $1; + $single_ret_by_ref = 0; + $single_ret_check = " == NULL"; + } elsif ($ret_member =~ m/remote_nonnull_domain_snapshot (\S+);/) { + push(@vars_list, "virDomainSnapshotPtr $1 = NULL"); + push(@ret_list, "make_nonnull_domain_snapshot(&ret->$1, $1);"); + push(@free_list, + " if ($1)\n" . + " virDomainSnapshotFree($1);"); + $single_ret_var = $1; + $single_ret_by_ref = 0; + $single_ret_check = " == NULL"; } elsif ($ret_member =~ m/int (\S+);/) { push(@vars_list, "int $1"); push(@ret_list, "ret->$1 = $1;"); @@ -539,7 +590,8 @@ elsif ($opt_b) { push(@ret_list, "ret->$1 = $1;"); $single_ret_var = $1; - if ($calls{$_}->{ProcName} eq "DomainGetMaxMemory") { + if ($calls{$_}->{ProcName} eq "DomainGetMaxMemory" or + $calls{$_}->{ProcName} eq "NodeGetFreeMemory") { $single_ret_by_ref = 0; $single_ret_check = " == 0"; } else { @@ -578,7 +630,10 @@ elsif ($opt_b) { if (! @args_list) { push(@args_list, "conn"); - $prefix = "Connect" + + if ($calls{$_}->{ProcName} ne "NodeGetFreeMemory") { + $prefix = "Connect" + } } if ($calls{$_}->{ProcName} eq "GetSysinfo" or -- 1.7.0.4 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list