From 7a3da17a585b2cdea07719499f55594d19072931 Mon Sep 17 00:00:00 2001 From: Daniel Veillard Date: Thu, 1 Apr 2010 10:54:12 +0200 Subject: [PATCH] Implement remote protocol for managed save * src/remote/remote_protocol.x src/remote/remote_protocol.h src/remote/remote_protocol.c src/remote/remote_driver.c: add the entry points in the remote driver * daemon/remote.c daemon/remote_dispatch_args.h daemon/remote_dispatch_prototypes.h daemon/remote_dispatch_table.h: and implement the daemon counterpart --- daemon/remote.c | 79 +++++++++++++++++++++++++++++ daemon/remote_dispatch_args.h | 3 ++ daemon/remote_dispatch_prototypes.h | 24 +++++++++ daemon/remote_dispatch_ret.h | 1 + daemon/remote_dispatch_table.h | 15 ++++++ src/remote/remote_driver.c | 79 +++++++++++++++++++++++++++-- src/remote/remote_protocol.c | 42 +++++++++++++++ src/remote/remote_protocol.h | 34 +++++++++++++ src/remote/remote_protocol.x | 24 ++++++++- 9 files changed, 297 insertions(+), 4 deletions(-) diff --git a/daemon/remote.c b/daemon/remote.c index 67162d5d45..780d53614f 100644 --- a/daemon/remote.c +++ b/daemon/remote.c @@ -2415,6 +2415,85 @@ remoteDispatchListDomains (struct qemud_server *server ATTRIBUTE_UNUSED, return 0; } +static int +remoteDispatchDomainManagedSave (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_managed_save_args *args, + void *ret ATTRIBUTE_UNUSED) +{ + virDomainPtr dom; + + dom = get_nonnull_domain (conn, args->dom); + if (dom == NULL) { + remoteDispatchConnError(rerr, conn); + return -1; + } + + if (virDomainManagedSave (dom, args->flags) == -1) { + virDomainFree(dom); + remoteDispatchConnError(rerr, conn); + return -1; + } + virDomainFree(dom); + return 0; +} + +static int +remoteDispatchDomainHasManagedSaveImage (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_has_managed_save_image_args *args, + remote_domain_has_managed_save_image_ret *ret) +{ + virDomainPtr dom; + + dom = get_nonnull_domain (conn, args->dom); + if (dom == NULL) { + remoteDispatchConnError(rerr, conn); + return -1; + } + + ret->ret = virDomainHasManagedSaveImage (dom, args->flags); + if (ret->ret == -1) { + virDomainFree(dom); + remoteDispatchConnError(rerr, conn); + return -1; + } + virDomainFree(dom); + return 0; +} + +static int +remoteDispatchDomainManagedSaveRemove (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_managed_save_remove_args *args, + void *ret ATTRIBUTE_UNUSED) +{ + virDomainPtr dom; + + dom = get_nonnull_domain (conn, args->dom); + if (dom == NULL) { + remoteDispatchConnError(rerr, conn); + return -1; + } + + if (virDomainManagedSaveRemove (dom, args->flags) == -1) { + virDomainFree(dom); + remoteDispatchConnError(rerr, conn); + return -1; + } + virDomainFree(dom); + return 0; +} + static int remoteDispatchListNetworks (struct qemud_server *server ATTRIBUTE_UNUSED, struct qemud_client *client ATTRIBUTE_UNUSED, diff --git a/daemon/remote_dispatch_args.h b/daemon/remote_dispatch_args.h index b188e6e6df..51c1675953 100644 --- a/daemon/remote_dispatch_args.h +++ b/daemon/remote_dispatch_args.h @@ -151,3 +151,6 @@ remote_list_nwfilters_args val_remote_list_nwfilters_args; remote_nwfilter_define_xml_args val_remote_nwfilter_define_xml_args; remote_nwfilter_undefine_args val_remote_nwfilter_undefine_args; + remote_domain_managed_save_args val_remote_domain_managed_save_args; + remote_domain_has_managed_save_image_args val_remote_domain_has_managed_save_image_args; + remote_domain_managed_save_remove_args val_remote_domain_managed_save_remove_args; diff --git a/daemon/remote_dispatch_prototypes.h b/daemon/remote_dispatch_prototypes.h index e155c69789..c33c1440c6 100644 --- a/daemon/remote_dispatch_prototypes.h +++ b/daemon/remote_dispatch_prototypes.h @@ -282,6 +282,14 @@ static int remoteDispatchDomainGetVcpus( remote_error *err, remote_domain_get_vcpus_args *args, remote_domain_get_vcpus_ret *ret); +static int remoteDispatchDomainHasManagedSaveImage( + struct qemud_server *server, + struct qemud_client *client, + virConnectPtr conn, + remote_message_header *hdr, + remote_error *err, + remote_domain_has_managed_save_image_args *args, + remote_domain_has_managed_save_image_ret *ret); static int remoteDispatchDomainInterfaceStats( struct qemud_server *server, struct qemud_client *client, @@ -330,6 +338,22 @@ static int remoteDispatchDomainLookupByUuid( remote_error *err, remote_domain_lookup_by_uuid_args *args, remote_domain_lookup_by_uuid_ret *ret); +static int remoteDispatchDomainManagedSave( + struct qemud_server *server, + struct qemud_client *client, + virConnectPtr conn, + remote_message_header *hdr, + remote_error *err, + remote_domain_managed_save_args *args, + void *ret); +static int remoteDispatchDomainManagedSaveRemove( + struct qemud_server *server, + struct qemud_client *client, + virConnectPtr conn, + remote_message_header *hdr, + remote_error *err, + remote_domain_managed_save_remove_args *args, + void *ret); static int remoteDispatchDomainMemoryPeek( struct qemud_server *server, struct qemud_client *client, diff --git a/daemon/remote_dispatch_ret.h b/daemon/remote_dispatch_ret.h index b134f256d0..84f401b362 100644 --- a/daemon/remote_dispatch_ret.h +++ b/daemon/remote_dispatch_ret.h @@ -125,3 +125,4 @@ remote_num_of_nwfilters_ret val_remote_num_of_nwfilters_ret; remote_list_nwfilters_ret val_remote_list_nwfilters_ret; remote_nwfilter_define_xml_ret val_remote_nwfilter_define_xml_ret; + remote_domain_has_managed_save_image_ret val_remote_domain_has_managed_save_image_ret; diff --git a/daemon/remote_dispatch_table.h b/daemon/remote_dispatch_table.h index 24756d72c3..bda7af21f4 100644 --- a/daemon/remote_dispatch_table.h +++ b/daemon/remote_dispatch_table.h @@ -912,3 +912,18 @@ .args_filter = (xdrproc_t) xdr_remote_nwfilter_undefine_args, .ret_filter = (xdrproc_t) xdr_void, }, +{ /* DomainManagedSave => 182 */ + .fn = (dispatch_fn) remoteDispatchDomainManagedSave, + .args_filter = (xdrproc_t) xdr_remote_domain_managed_save_args, + .ret_filter = (xdrproc_t) xdr_void, +}, +{ /* DomainHasManagedSaveImage => 183 */ + .fn = (dispatch_fn) remoteDispatchDomainHasManagedSaveImage, + .args_filter = (xdrproc_t) xdr_remote_domain_has_managed_save_image_args, + .ret_filter = (xdrproc_t) xdr_remote_domain_has_managed_save_image_ret, +}, +{ /* DomainManagedSaveRemove => 184 */ + .fn = (dispatch_fn) remoteDispatchDomainManagedSaveRemove, + .args_filter = (xdrproc_t) xdr_remote_domain_managed_save_remove_args, + .ret_filter = (xdrproc_t) xdr_void, +}, diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c index 9b500d0901..ede00e8920 100644 --- a/src/remote/remote_driver.c +++ b/src/remote/remote_driver.c @@ -3616,6 +3616,79 @@ done: return rv; } +static int +remoteDomainManagedSave (virDomainPtr domain, unsigned int flags) +{ + int rv = -1; + remote_domain_managed_save_args args; + struct private_data *priv = domain->conn->privateData; + + remoteDriverLock(priv); + + make_nonnull_domain (&args.dom, domain); + args.flags = flags; + + if (call (domain->conn, priv, 0, REMOTE_PROC_DOMAIN_MANAGED_SAVE, + (xdrproc_t) xdr_remote_domain_managed_save_args, (char *) &args, + (xdrproc_t) xdr_void, (char *) NULL) == -1) + goto done; + + rv = 0; + +done: + remoteDriverUnlock(priv); + return rv; +} + +static int +remoteDomainHasManagedSaveImage (virDomainPtr domain, unsigned int flags) +{ + int rv = -1; + remote_domain_has_managed_save_image_args args; + remote_domain_has_managed_save_image_ret ret; + struct private_data *priv = domain->conn->privateData; + + remoteDriverLock(priv); + + make_nonnull_domain (&args.dom, domain); + args.flags = flags; + + if (call (domain->conn, priv, 0, REMOTE_PROC_DOMAIN_HAS_MANAGED_SAVE_IMAGE, + (xdrproc_t) xdr_remote_domain_has_managed_save_image_args, (char *) &args, + (xdrproc_t) xdr_remote_domain_has_managed_save_image_ret, (char *) &ret) == -1) + goto done; + + rv = ret.ret; + +done: + remoteDriverUnlock(priv); + return rv; +} + +static int +remoteDomainManagedSaveRemove (virDomainPtr domain, unsigned int flags) +{ + int rv = -1; + remote_domain_managed_save_remove_args args; + struct private_data *priv = domain->conn->privateData; + + remoteDriverLock(priv); + + make_nonnull_domain (&args.dom, domain); + args.flags = flags; + + if (call (domain->conn, priv, 0, REMOTE_PROC_DOMAIN_MANAGED_SAVE_REMOVE, + (xdrproc_t) xdr_remote_domain_managed_save_remove_args, (char *) &args, + (xdrproc_t) xdr_void, (char *) NULL) == -1) + goto done; + + rv = 0; + +done: + remoteDriverUnlock(priv); + return rv; +} + /*----------------------------------------------------------------------*/ static virDrvOpenStatus ATTRIBUTE_NONNULL (1) @@ -9818,9 +9891,9 @@ static virDriver remote_driver = { remoteDomainMigrateSetMaxDowntime, /* domainMigrateSetMaxDowntime */ remoteDomainEventRegisterAny, /* domainEventRegisterAny */ remoteDomainEventDeregisterAny, /* domainEventDeregisterAny */ - NULL, /* domainManagedSave */ - NULL, /* domainHasManagedSaveImage */ - NULL, /* domainManagedSaveRemove */ + remoteDomainManagedSave, /* domainManagedSave */ + remoteDomainHasManagedSaveImage, /* domainHasManagedSaveImage */ + remoteDomainManagedSaveRemove, /* domainManagedSaveRemove */ }; static virNetworkDriver network_driver = { diff --git a/src/remote/remote_protocol.c b/src/remote/remote_protocol.c index f252d85651..68b827a1f1 100644 --- a/src/remote/remote_protocol.c +++ b/src/remote/remote_protocol.c @@ -3288,6 +3288,48 @@ xdr_remote_domain_event_graphics_msg (XDR *xdrs, remote_domain_event_graphics_ms return TRUE; } +bool_t +xdr_remote_domain_managed_save_args (XDR *xdrs, remote_domain_managed_save_args *objp) +{ + + if (!xdr_remote_nonnull_domain (xdrs, &objp->dom)) + return FALSE; + if (!xdr_u_int (xdrs, &objp->flags)) + return FALSE; + return TRUE; +} + +bool_t +xdr_remote_domain_has_managed_save_image_args (XDR *xdrs, remote_domain_has_managed_save_image_args *objp) +{ + + if (!xdr_remote_nonnull_domain (xdrs, &objp->dom)) + return FALSE; + if (!xdr_u_int (xdrs, &objp->flags)) + return FALSE; + return TRUE; +} + +bool_t +xdr_remote_domain_has_managed_save_image_ret (XDR *xdrs, remote_domain_has_managed_save_image_ret *objp) +{ + + if (!xdr_int (xdrs, &objp->ret)) + return FALSE; + return TRUE; +} + +bool_t +xdr_remote_domain_managed_save_remove_args (XDR *xdrs, remote_domain_managed_save_remove_args *objp) +{ + + if (!xdr_remote_nonnull_domain (xdrs, &objp->dom)) + return FALSE; + if (!xdr_u_int (xdrs, &objp->flags)) + return FALSE; + return TRUE; +} + bool_t xdr_remote_procedure (XDR *xdrs, remote_procedure *objp) { diff --git a/src/remote/remote_protocol.h b/src/remote/remote_protocol.h index d898502a80..6558948feb 100644 --- a/src/remote/remote_protocol.h +++ b/src/remote/remote_protocol.h @@ -1860,6 +1860,29 @@ struct remote_domain_event_graphics_msg { } subject; }; typedef struct remote_domain_event_graphics_msg remote_domain_event_graphics_msg; + +struct remote_domain_managed_save_args { + remote_nonnull_domain dom; + u_int flags; +}; +typedef struct remote_domain_managed_save_args remote_domain_managed_save_args; + +struct remote_domain_has_managed_save_image_args { + remote_nonnull_domain dom; + u_int flags; +}; +typedef struct remote_domain_has_managed_save_image_args remote_domain_has_managed_save_image_args; + +struct remote_domain_has_managed_save_image_ret { + int ret; +}; +typedef struct remote_domain_has_managed_save_image_ret remote_domain_has_managed_save_image_ret; + +struct remote_domain_managed_save_remove_args { + remote_nonnull_domain dom; + u_int flags; +}; +typedef struct remote_domain_managed_save_remove_args remote_domain_managed_save_remove_args; #define REMOTE_PROGRAM 0x20008086 #define REMOTE_PROTOCOL_VERSION 1 @@ -2045,6 +2068,9 @@ enum remote_procedure { REMOTE_PROC_LIST_NWFILTERS = 179, REMOTE_PROC_NWFILTER_DEFINE_XML = 180, REMOTE_PROC_NWFILTER_UNDEFINE = 181, + REMOTE_PROC_DOMAIN_MANAGED_SAVE = 182, + REMOTE_PROC_DOMAIN_HAS_MANAGED_SAVE_IMAGE = 183, + REMOTE_PROC_DOMAIN_MANAGED_SAVE_REMOVE = 184, }; typedef enum remote_procedure remote_procedure; @@ -2380,6 +2406,10 @@ extern bool_t xdr_remote_domain_event_io_error_msg (XDR *, remote_domain_event_ extern bool_t xdr_remote_domain_event_graphics_address (XDR *, remote_domain_event_graphics_address*); extern bool_t xdr_remote_domain_event_graphics_identity (XDR *, remote_domain_event_graphics_identity*); extern bool_t xdr_remote_domain_event_graphics_msg (XDR *, remote_domain_event_graphics_msg*); +extern bool_t xdr_remote_domain_managed_save_args (XDR *, remote_domain_managed_save_args*); +extern bool_t xdr_remote_domain_has_managed_save_image_args (XDR *, remote_domain_has_managed_save_image_args*); +extern bool_t xdr_remote_domain_has_managed_save_image_ret (XDR *, remote_domain_has_managed_save_image_ret*); +extern bool_t xdr_remote_domain_managed_save_remove_args (XDR *, remote_domain_managed_save_remove_args*); extern bool_t xdr_remote_procedure (XDR *, remote_procedure*); extern bool_t xdr_remote_message_type (XDR *, remote_message_type*); extern bool_t xdr_remote_message_status (XDR *, remote_message_status*); @@ -2689,6 +2719,10 @@ extern bool_t xdr_remote_domain_event_io_error_msg (); extern bool_t xdr_remote_domain_event_graphics_address (); extern bool_t xdr_remote_domain_event_graphics_identity (); extern bool_t xdr_remote_domain_event_graphics_msg (); +extern bool_t xdr_remote_domain_managed_save_args (); +extern bool_t xdr_remote_domain_has_managed_save_image_args (); +extern bool_t xdr_remote_domain_has_managed_save_image_ret (); +extern bool_t xdr_remote_domain_managed_save_remove_args (); extern bool_t xdr_remote_procedure (); extern bool_t xdr_remote_message_type (); extern bool_t xdr_remote_message_status (); diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x index bf87c33dcd..0374f9a9dc 100644 --- a/src/remote/remote_protocol.x +++ b/src/remote/remote_protocol.x @@ -1647,6 +1647,25 @@ struct remote_domain_event_graphics_msg { remote_domain_event_graphics_identity subject; }; +struct remote_domain_managed_save_args { + remote_nonnull_domain dom; + unsigned flags; +}; + +struct remote_domain_has_managed_save_image_args { + remote_nonnull_domain dom; + unsigned flags; +}; + +struct remote_domain_has_managed_save_image_ret { + int ret; +}; + +struct remote_domain_managed_save_remove_args { + remote_nonnull_domain dom; + unsigned flags; +}; + /*----- Protocol. -----*/ /* Define the program number, protocol version and procedure numbers here. */ @@ -1852,7 +1871,10 @@ enum remote_procedure { REMOTE_PROC_LIST_NWFILTERS = 179, REMOTE_PROC_NWFILTER_DEFINE_XML = 180, - REMOTE_PROC_NWFILTER_UNDEFINE = 181 + REMOTE_PROC_NWFILTER_UNDEFINE = 181, + REMOTE_PROC_DOMAIN_MANAGED_SAVE = 182, + REMOTE_PROC_DOMAIN_HAS_MANAGED_SAVE_IMAGE = 183, + REMOTE_PROC_DOMAIN_MANAGED_SAVE_REMOVE = 184 /* * Notice how the entries are grouped in sets of 10 ? -- GitLab