* src/remote/remote_protocol.x: provide defines for the new entry points
* src/remote/remote_driver.c daemon/remote.c: implement the client and
server side
* daemon/remote_dispatch_args.h daemon/remote_dispatch_prototypes.h
daemon/remote_dispatch_ret.h daemon/remote_dispatch_table.h
src/remote/remote_protocol.c src/remote/remote_protocol.h: generated
stubs
Signed-off-by: Adam Litke <agl(a)us.ibm.com>
---
daemon/remote.c | 96 +++++++++++++++++++++++++++++++++++
daemon/remote_dispatch_args.h | 2 +
daemon/remote_dispatch_prototypes.h | 16 ++++++
daemon/remote_dispatch_ret.h | 2 +
daemon/remote_dispatch_table.h | 10 ++++
src/remote/remote_driver.c | 87 +++++++++++++++++++++++++++++++-
src/remote/remote_protocol.c | 63 +++++++++++++++++++++++
src/remote/remote_protocol.h | 51 ++++++++++++++++++
src/remote/remote_protocol.x | 37 +++++++++++++-
9 files changed, 361 insertions(+), 3 deletions(-)
diff --git a/daemon/remote.c b/daemon/remote.c
index dd85ef1..87bb11b 100644
--- a/daemon/remote.c
+++ b/daemon/remote.c
@@ -7024,6 +7024,102 @@ cleanup:
return rc;
}
+static int
+remoteDispatchDomainStreamDisk (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_stream_disk_args *args,
+ remote_domain_stream_disk_ret *ret)
+{
+ virDomainPtr dom;
+ const char *path;
+ unsigned long long offset;
+ unsigned int flags;
+ int rc;
+
+ dom = get_nonnull_domain (conn, args->dom);
+ if (dom == NULL) {
+ remoteDispatchConnError(rerr, conn);
+ return -1;
+ }
+
+ path = args->path;
+ offset = args->offset;
+ flags = args->flags;
+
+ rc = virDomainStreamDisk(dom, path, offset, flags);
+ if (rc == (unsigned long long) -1) {
+ remoteDispatchConnError(rerr, conn);
+ return -1;
+ }
+ ret->offset = rc;
+ return 0;
+}
+
+static int
+remoteDispatchDomainStreamDiskInfo (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_stream_disk_info_args *args,
+ remote_domain_stream_disk_info_ret *ret)
+{
+ virDomainPtr dom;
+ struct _virStreamDiskState *states;
+ unsigned int nr_states, flags, i;
+ int nr_returned;
+
+ if (args->nr_results > REMOTE_DOMAIN_STREAM_DISK_STATES_MAX) {
+ remoteDispatchFormatError (rerr, "%s",
+ _("nr_results >
REMOTE_DOMAIN_STREAM_DISK_STATES_MAX"));
+ return -1;
+ }
+
+ dom = get_nonnull_domain (conn, args->dom);
+ if (dom == NULL) {
+ remoteDispatchConnError(rerr, conn);
+ return -1;
+ }
+
+ nr_states = args->nr_results;
+ flags = args->flags;
+
+ /* Allocate array of stats structs for making dispatch call */
+ if (VIR_ALLOC_N(states, nr_states) < 0) {
+ virDomainFree (dom);
+ remoteDispatchOOMError(rerr);
+ return -1;
+ }
+
+ nr_returned = virDomainStreamDiskInfo (dom, states, nr_states, flags);
+ virDomainFree (dom);
+ if (nr_returned < 0) {
+ VIR_FREE(states);
+ remoteDispatchConnError(rerr, conn);
+ return -1;
+ }
+
+ /* Allocate return buffer */
+ if (VIR_ALLOC_N(ret->states.states_val, nr_returned) < 0) {
+ VIR_FREE(states);
+ remoteDispatchOOMError(rerr);
+ return -1;
+ }
+
+ /* Copy the stats into the return structure */
+ ret->states.states_len = nr_returned;
+ for (i = 0; i < nr_returned; i++) {
+ ret->states.states_val[i].path.path_val = strdup(states[i].path);
+ ret->states.states_val[i].path.path_len = strlen(states[i].path);
+ ret->states.states_val[i].offset = states[i].offset;
+ ret->states.states_val[i].size = states[i].size;
+ }
+ VIR_FREE(states);
+ return 0;
+}
static int
remoteDispatchDomainEventsRegisterAny (struct qemud_server *server ATTRIBUTE_UNUSED,
diff --git a/daemon/remote_dispatch_args.h b/daemon/remote_dispatch_args.h
index f9537d7..c36a836 100644
--- a/daemon/remote_dispatch_args.h
+++ b/daemon/remote_dispatch_args.h
@@ -178,3 +178,5 @@
remote_domain_migrate_set_max_speed_args
val_remote_domain_migrate_set_max_speed_args;
remote_storage_vol_upload_args val_remote_storage_vol_upload_args;
remote_storage_vol_download_args val_remote_storage_vol_download_args;
+ remote_domain_stream_disk_args val_remote_domain_stream_disk_args;
+ remote_domain_stream_disk_info_args val_remote_domain_stream_disk_info_args;
diff --git a/daemon/remote_dispatch_prototypes.h b/daemon/remote_dispatch_prototypes.h
index 18bf41d..de9c5bb 100644
--- a/daemon/remote_dispatch_prototypes.h
+++ b/daemon/remote_dispatch_prototypes.h
@@ -682,6 +682,22 @@ static int remoteDispatchDomainSnapshotNum(
remote_error *err,
remote_domain_snapshot_num_args *args,
remote_domain_snapshot_num_ret *ret);
+static int remoteDispatchDomainStreamDisk(
+ struct qemud_server *server,
+ struct qemud_client *client,
+ virConnectPtr conn,
+ remote_message_header *hdr,
+ remote_error *err,
+ remote_domain_stream_disk_args *args,
+ remote_domain_stream_disk_ret *ret);
+static int remoteDispatchDomainStreamDiskInfo(
+ struct qemud_server *server,
+ struct qemud_client *client,
+ virConnectPtr conn,
+ remote_message_header *hdr,
+ remote_error *err,
+ remote_domain_stream_disk_info_args *args,
+ remote_domain_stream_disk_info_ret *ret);
static int remoteDispatchDomainSuspend(
struct qemud_server *server,
struct qemud_client *client,
diff --git a/daemon/remote_dispatch_ret.h b/daemon/remote_dispatch_ret.h
index 114e832..2e2df6e 100644
--- a/daemon/remote_dispatch_ret.h
+++ b/daemon/remote_dispatch_ret.h
@@ -140,3 +140,5 @@
remote_domain_is_updated_ret val_remote_domain_is_updated_ret;
remote_get_sysinfo_ret val_remote_get_sysinfo_ret;
remote_domain_get_blkio_parameters_ret val_remote_domain_get_blkio_parameters_ret;
+ remote_domain_stream_disk_ret val_remote_domain_stream_disk_ret;
+ remote_domain_stream_disk_info_ret val_remote_domain_stream_disk_info_ret;
diff --git a/daemon/remote_dispatch_table.h b/daemon/remote_dispatch_table.h
index b39f7c2..100b274 100644
--- a/daemon/remote_dispatch_table.h
+++ b/daemon/remote_dispatch_table.h
@@ -1052,3 +1052,13 @@
.args_filter = (xdrproc_t) xdr_remote_storage_vol_download_args,
.ret_filter = (xdrproc_t) xdr_void,
},
+{ /* DomainStreamDisk => 210 */
+ .fn = (dispatch_fn) remoteDispatchDomainStreamDisk,
+ .args_filter = (xdrproc_t) xdr_remote_domain_stream_disk_args,
+ .ret_filter = (xdrproc_t) xdr_remote_domain_stream_disk_ret,
+},
+{ /* DomainStreamDiskInfo => 211 */
+ .fn = (dispatch_fn) remoteDispatchDomainStreamDiskInfo,
+ .args_filter = (xdrproc_t) xdr_remote_domain_stream_disk_info_args,
+ .ret_filter = (xdrproc_t) xdr_remote_domain_stream_disk_info_ret,
+},
diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
index 29c9ff6..95ed42f 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -9511,6 +9511,89 @@ done:
return rv;
}
+static unsigned long long
+remoteDomainStreamDisk(virDomainPtr domain, const char *path,
+ unsigned long long offset, unsigned int flags)
+{
+ unsigned long long rv = (unsigned long long) -1;
+
+ remote_domain_stream_disk_args args;
+ remote_domain_stream_disk_ret ret;
+ struct private_data *priv = domain->conn->privateData;
+
+ args.offset = offset;
+ args.flags = flags;
+ args.path = strdup(path);
+ if (args.path == NULL) {
+ virReportOOMError();
+ return -1;
+ }
+
+ remoteDriverLock(priv);
+ make_nonnull_domain (&args.dom, domain);
+ memset (&ret, 0, sizeof ret);
+
+ if (call (domain->conn, priv, 0, REMOTE_PROC_DOMAIN_STREAM_DISK,
+ (xdrproc_t) xdr_remote_domain_stream_disk_args,
+ (char *) &args,
+ (xdrproc_t) xdr_remote_domain_stream_disk_ret,
+ (char *) &ret) == -1)
+ goto done;
+
+ rv = ret.offset;
+ xdr_free((xdrproc_t) xdr_remote_domain_stream_disk_ret, (char *) &ret);
+
+done:
+ remoteDriverUnlock(priv);
+ VIR_FREE(args.path);
+ return rv;
+}
+
+static int remoteDomainStreamDiskInfo(virDomainPtr domain,
+ virStreamDiskStatePtr states,
+ unsigned int nr_states,
+ unsigned int flags)
+{
+ int rv = -1;
+ remote_domain_stream_disk_info_args args;
+ remote_domain_stream_disk_info_ret ret;
+ struct private_data *priv = domain->conn->privateData;
+ unsigned int i;
+
+ remoteDriverLock(priv);
+
+ make_nonnull_domain (&args.dom, domain);
+ if (nr_states > REMOTE_DOMAIN_STREAM_DISK_STATES_MAX) {
+ remoteError(VIR_ERR_RPC,
+ _("too many disk stream stats requested: %d > %d"),
+ nr_states, REMOTE_DOMAIN_STREAM_DISK_STATES_MAX);
+ goto done;
+ }
+ args.nr_results = nr_states;
+ args.flags = flags;
+ memset (&ret, 0, sizeof ret);
+
+ if (call (domain->conn, priv, 0, REMOTE_PROC_DOMAIN_STREAM_DISK_INFO,
+ (xdrproc_t) xdr_remote_domain_stream_disk_info_args,
+ (char *) &args,
+ (xdrproc_t) xdr_remote_domain_stream_disk_info_ret,
+ (char *) &ret) == -1)
+ goto done;
+
+ for (i = 0; i < ret.states.states_len; i++) {
+ strncpy (states[i].path, ret.states.states_val[i].path.path_val,
+ VIR_STREAM_PATH_BUFLEN);
+ states[i].offset = ret.states.states_val[i].offset;
+ states[i].size = ret.states.states_val[i].size;
+ }
+ rv = ret.states.states_len;
+ xdr_free((xdrproc_t) xdr_remote_domain_stream_disk_info_ret, (char *) &ret);
+
+done:
+ remoteDriverUnlock(priv);
+ return rv;
+}
+
static int remoteDomainEventRegisterAny(virConnectPtr conn,
virDomainPtr dom,
int eventID,
@@ -11300,8 +11383,8 @@ static virDriver remote_driver = {
remoteDomainSnapshotDelete, /* domainSnapshotDelete */
remoteQemuDomainMonitorCommand, /* qemuDomainMonitorCommand */
remoteDomainOpenConsole, /* domainOpenConsole */
- NULL, /* domainStreamDisk */
- NULL, /* domainStreamDiskInfo */
+ remoteDomainStreamDisk, /* domainStreamDisk */
+ remoteDomainStreamDiskInfo, /* domainStreamDiskInfo */
};
static virNetworkDriver network_driver = {
diff --git a/src/remote/remote_protocol.c b/src/remote/remote_protocol.c
index 5604371..6b79767 100644
--- a/src/remote/remote_protocol.c
+++ b/src/remote/remote_protocol.c
@@ -1693,6 +1693,69 @@ xdr_remote_domain_set_autostart_args (XDR *xdrs,
remote_domain_set_autostart_arg
}
bool_t
+xdr_remote_domain_stream_disk_args (XDR *xdrs, remote_domain_stream_disk_args *objp)
+{
+
+ if (!xdr_remote_nonnull_domain (xdrs, &objp->dom))
+ return FALSE;
+ if (!xdr_remote_nonnull_string (xdrs, &objp->path))
+ return FALSE;
+ if (!xdr_uint64_t (xdrs, &objp->offset))
+ return FALSE;
+ if (!xdr_u_int (xdrs, &objp->flags))
+ return FALSE;
+ return TRUE;
+}
+
+bool_t
+xdr_remote_domain_stream_disk_ret (XDR *xdrs, remote_domain_stream_disk_ret *objp)
+{
+
+ if (!xdr_uint64_t (xdrs, &objp->offset))
+ return FALSE;
+ return TRUE;
+}
+
+bool_t
+xdr_remote_domain_stream_disk_info_args (XDR *xdrs, remote_domain_stream_disk_info_args
*objp)
+{
+
+ if (!xdr_remote_nonnull_domain (xdrs, &objp->dom))
+ return FALSE;
+ if (!xdr_u_int (xdrs, &objp->nr_results))
+ return FALSE;
+ if (!xdr_u_int (xdrs, &objp->flags))
+ return FALSE;
+ return TRUE;
+}
+
+bool_t
+xdr_remote_stream_disk_state (XDR *xdrs, remote_stream_disk_state *objp)
+{
+ char **objp_cpp0 = (char **) (void *) &objp->path.path_val;
+
+ if (!xdr_array (xdrs, objp_cpp0, (u_int *) &objp->path.path_len,
VIR_STREAM_PATH_BUFLEN,
+ sizeof (char), (xdrproc_t) xdr_char))
+ return FALSE;
+ if (!xdr_uint64_t (xdrs, &objp->offset))
+ return FALSE;
+ if (!xdr_uint64_t (xdrs, &objp->size))
+ return FALSE;
+ return TRUE;
+}
+
+bool_t
+xdr_remote_domain_stream_disk_info_ret (XDR *xdrs, remote_domain_stream_disk_info_ret
*objp)
+{
+ char **objp_cpp0 = (char **) (void *) &objp->states.states_val;
+
+ if (!xdr_array (xdrs, objp_cpp0, (u_int *) &objp->states.states_len,
REMOTE_DOMAIN_STREAM_DISK_STATES_MAX,
+ sizeof (remote_stream_disk_state), (xdrproc_t)
xdr_remote_stream_disk_state))
+ return FALSE;
+ return TRUE;
+}
+
+bool_t
xdr_remote_num_of_networks_ret (XDR *xdrs, remote_num_of_networks_ret *objp)
{
diff --git a/src/remote/remote_protocol.h b/src/remote/remote_protocol.h
index d9bf151..88fa0e6 100644
--- a/src/remote/remote_protocol.h
+++ b/src/remote/remote_protocol.h
@@ -68,6 +68,7 @@ typedef remote_nonnull_string *remote_string;
#define REMOTE_SECRET_VALUE_MAX 65536
#define REMOTE_SECRET_UUID_LIST_MAX 16384
#define REMOTE_CPU_BASELINE_MAX 256
+#define REMOTE_DOMAIN_STREAM_DISK_STATES_MAX VIR_STREAM_DISK_MAX_STREAMS
typedef char remote_uuid[VIR_UUID_BUFLEN];
@@ -945,6 +946,44 @@ struct remote_domain_set_autostart_args {
};
typedef struct remote_domain_set_autostart_args remote_domain_set_autostart_args;
+struct remote_domain_stream_disk_args {
+ remote_nonnull_domain dom;
+ remote_nonnull_string path;
+ uint64_t offset;
+ u_int flags;
+};
+typedef struct remote_domain_stream_disk_args remote_domain_stream_disk_args;
+
+struct remote_domain_stream_disk_ret {
+ uint64_t offset;
+};
+typedef struct remote_domain_stream_disk_ret remote_domain_stream_disk_ret;
+
+struct remote_domain_stream_disk_info_args {
+ remote_nonnull_domain dom;
+ u_int nr_results;
+ u_int flags;
+};
+typedef struct remote_domain_stream_disk_info_args remote_domain_stream_disk_info_args;
+
+struct remote_stream_disk_state {
+ struct {
+ u_int path_len;
+ char *path_val;
+ } path;
+ uint64_t offset;
+ uint64_t size;
+};
+typedef struct remote_stream_disk_state remote_stream_disk_state;
+
+struct remote_domain_stream_disk_info_ret {
+ struct {
+ u_int states_len;
+ remote_stream_disk_state *states_val;
+ } states;
+};
+typedef struct remote_domain_stream_disk_info_ret remote_domain_stream_disk_info_ret;
+
struct remote_num_of_networks_ret {
int num;
};
@@ -2413,6 +2452,8 @@ enum remote_procedure {
REMOTE_PROC_DOMAIN_MIGRATE_SET_MAX_SPEED = 207,
REMOTE_PROC_STORAGE_VOL_UPLOAD = 208,
REMOTE_PROC_STORAGE_VOL_DOWNLOAD = 209,
+ REMOTE_PROC_DOMAIN_STREAM_DISK = 210,
+ REMOTE_PROC_DOMAIN_STREAM_DISK_INFO = 211,
};
typedef enum remote_procedure remote_procedure;
@@ -2581,6 +2622,11 @@ extern bool_t xdr_remote_domain_update_device_flags_args (XDR *,
remote_domain_
extern bool_t xdr_remote_domain_get_autostart_args (XDR *,
remote_domain_get_autostart_args*);
extern bool_t xdr_remote_domain_get_autostart_ret (XDR *,
remote_domain_get_autostart_ret*);
extern bool_t xdr_remote_domain_set_autostart_args (XDR *,
remote_domain_set_autostart_args*);
+extern bool_t xdr_remote_domain_stream_disk_args (XDR *,
remote_domain_stream_disk_args*);
+extern bool_t xdr_remote_domain_stream_disk_ret (XDR *,
remote_domain_stream_disk_ret*);
+extern bool_t xdr_remote_domain_stream_disk_info_args (XDR *,
remote_domain_stream_disk_info_args*);
+extern bool_t xdr_remote_stream_disk_state (XDR *, remote_stream_disk_state*);
+extern bool_t xdr_remote_domain_stream_disk_info_ret (XDR *,
remote_domain_stream_disk_info_ret*);
extern bool_t xdr_remote_num_of_networks_ret (XDR *, remote_num_of_networks_ret*);
extern bool_t xdr_remote_list_networks_args (XDR *, remote_list_networks_args*);
extern bool_t xdr_remote_list_networks_ret (XDR *, remote_list_networks_ret*);
@@ -2938,6 +2984,11 @@ extern bool_t xdr_remote_domain_update_device_flags_args ();
extern bool_t xdr_remote_domain_get_autostart_args ();
extern bool_t xdr_remote_domain_get_autostart_ret ();
extern bool_t xdr_remote_domain_set_autostart_args ();
+extern bool_t xdr_remote_domain_stream_disk_args ();
+extern bool_t xdr_remote_domain_stream_disk_ret ();
+extern bool_t xdr_remote_domain_stream_disk_info_args ();
+extern bool_t xdr_remote_stream_disk_state ();
+extern bool_t xdr_remote_domain_stream_disk_info_ret ();
extern bool_t xdr_remote_num_of_networks_ret ();
extern bool_t xdr_remote_list_networks_args ();
extern bool_t xdr_remote_list_networks_ret ();
diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x
index 675eccd..268aec7 100644
--- a/src/remote/remote_protocol.x
+++ b/src/remote/remote_protocol.x
@@ -191,6 +191,11 @@ const REMOTE_SECRET_UUID_LIST_MAX = 16384;
*/
const REMOTE_CPU_BASELINE_MAX = 256;
+/*
+ * Maximum number of active disk streams that can be reported
+ */
+const REMOTE_DOMAIN_STREAM_DISK_STATES_MAX = VIR_STREAM_DISK_MAX_STREAMS;
+
/* UUID. VIR_UUID_BUFLEN definition comes from libvirt.h */
typedef opaque remote_uuid[VIR_UUID_BUFLEN];
@@ -917,6 +922,33 @@ struct remote_domain_set_autostart_args {
int autostart;
};
+struct remote_domain_stream_disk_args {
+ remote_nonnull_domain dom;
+ remote_nonnull_string path;
+ unsigned hyper offset;
+ unsigned int flags;
+};
+
+struct remote_domain_stream_disk_ret {
+ unsigned hyper offset;
+};
+
+struct remote_domain_stream_disk_info_args {
+ remote_nonnull_domain dom;
+ unsigned int nr_results;
+ unsigned int flags;
+};
+
+struct remote_stream_disk_state {
+ char path<VIR_STREAM_PATH_BUFLEN>;
+ unsigned hyper offset;
+ unsigned hyper size;
+};
+
+struct remote_domain_stream_disk_info_ret {
+ remote_stream_disk_state states<REMOTE_DOMAIN_STREAM_DISK_STATES_MAX>;
+};
+
/* Network calls: */
struct remote_num_of_networks_ret {
@@ -2176,7 +2208,10 @@ enum remote_procedure {
REMOTE_PROC_DOMAIN_GET_BLKIO_PARAMETERS = 206,
REMOTE_PROC_DOMAIN_MIGRATE_SET_MAX_SPEED = 207,
REMOTE_PROC_STORAGE_VOL_UPLOAD = 208,
- REMOTE_PROC_STORAGE_VOL_DOWNLOAD = 209
+ REMOTE_PROC_STORAGE_VOL_DOWNLOAD = 209,
+ REMOTE_PROC_DOMAIN_STREAM_DISK = 210,
+
+ REMOTE_PROC_DOMAIN_STREAM_DISK_INFO = 211
/*
* Notice how the entries are grouped in sets of 10 ?
--
1.7.3