* daemon/remote.c, src/remote/remote_driver.c: Implementation
of storage vol upload/download APIs
* src/remote/remote_protocol.x: Wire protocol definition for
upload/download
* daemon/remote_dispatch_args.h, daemon/remote_dispatch_prototypes.h,
daemon/remote_dispatch_table.h, src/remote/remote_protocol.h,
src/remote/remote_protocol.c: Re-generate
---
daemon/remote.c | 92 +++++++++++++++++++++++++++++++++++
daemon/remote_dispatch_args.h | 2 +
daemon/remote_dispatch_prototypes.h | 16 ++++++
daemon/remote_dispatch_table.h | 10 ++++
src/remote/remote_driver.c | 92 +++++++++++++++++++++++++++++++++-
src/remote/remote_protocol.c | 30 +++++++++++
src/remote/remote_protocol.h | 22 ++++++++
src/remote/remote_protocol.x | 19 +++++++-
src/remote_protocol-structs | 12 +++++
9 files changed, 291 insertions(+), 4 deletions(-)
diff --git a/daemon/remote.c b/daemon/remote.c
index a8fef4d..8cadfc2 100644
--- a/daemon/remote.c
+++ b/daemon/remote.c
@@ -5816,7 +5816,99 @@ remoteDispatchNodeDeviceDestroy(struct qemud_server *server
ATTRIBUTE_UNUSED,
virNodeDeviceFree(dev);
return 0;
}
+static int remoteDispatchStorageVolUpload(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client,
+ virConnectPtr conn,
+ remote_message_header *hdr,
+ remote_error *rerr,
+ remote_storage_vol_upload_args *args,
+ void *ret ATTRIBUTE_UNUSED)
+{
+ int rv = -1;
+ struct qemud_client_stream *stream = NULL;
+ virStorageVolPtr vol;
+
+ vol = get_nonnull_storage_vol(conn, args->vol);
+ if (vol == NULL) {
+ remoteDispatchConnError(rerr, conn);
+ goto cleanup;
+ }
+
+ stream = remoteCreateClientStream(conn, hdr);
+ if (!stream) {
+ remoteDispatchConnError(rerr, conn);
+ goto cleanup;
+ }
+
+ if (virStorageVolUpload(vol, stream->st,
+ args->offset, args->length,
+ args->flags) < 0) {
+ remoteDispatchConnError(rerr, conn);
+ goto cleanup;
+ }
+
+ if (remoteAddClientStream(client, stream, 0) < 0) {
+ remoteDispatchConnError(rerr, conn);
+ virStreamAbort(stream->st);
+ goto cleanup;
+ }
+
+ rv = 0;
+
+cleanup:
+ if (vol)
+ virStorageVolFree(vol);
+ if (stream && rv != 0)
+ remoteFreeClientStream(client, stream);
+ return rv;
+}
+static int remoteDispatchStorageVolDownload(struct qemud_server *server
ATTRIBUTE_UNUSED,
+ struct qemud_client *client,
+ virConnectPtr conn,
+ remote_message_header *hdr,
+ remote_error *rerr,
+ remote_storage_vol_download_args *args,
+ void *ret ATTRIBUTE_UNUSED)
+{
+ int rv = -1;
+ struct qemud_client_stream *stream = NULL;
+ virStorageVolPtr vol;
+
+ vol = get_nonnull_storage_vol (conn, args->vol);
+ if (vol == NULL) {
+ remoteDispatchConnError(rerr, conn);
+ goto cleanup;
+ }
+
+ stream = remoteCreateClientStream(conn, hdr);
+ if (!stream) {
+ remoteDispatchConnError(rerr, conn);
+ goto cleanup;
+ }
+
+ if (virStorageVolDownload(vol, stream->st,
+ args->offset, args->length,
+ args->flags) < 0) {
+ remoteDispatchConnError(rerr, conn);
+ goto cleanup;
+ }
+
+ if (remoteAddClientStream(client, stream, 1) < 0) {
+ remoteDispatchConnError(rerr, conn);
+ virStreamAbort(stream->st);
+ goto cleanup;
+ }
+
+ rv = 0;
+
+cleanup:
+ if (vol)
+ virStorageVolFree(vol);
+ if (stream && rv != 0)
+ remoteFreeClientStream(client, stream);
+ return rv;
+}
/***************************
diff --git a/daemon/remote_dispatch_args.h b/daemon/remote_dispatch_args.h
index 15fa1a0..f9537d7 100644
--- a/daemon/remote_dispatch_args.h
+++ b/daemon/remote_dispatch_args.h
@@ -176,3 +176,5 @@
remote_domain_set_blkio_parameters_args val_remote_domain_set_blkio_parameters_args;
remote_domain_get_blkio_parameters_args val_remote_domain_get_blkio_parameters_args;
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;
diff --git a/daemon/remote_dispatch_prototypes.h b/daemon/remote_dispatch_prototypes.h
index 3fcf87c..18bf41d 100644
--- a/daemon/remote_dispatch_prototypes.h
+++ b/daemon/remote_dispatch_prototypes.h
@@ -1538,6 +1538,14 @@ static int remoteDispatchStorageVolDelete(
remote_error *err,
remote_storage_vol_delete_args *args,
void *ret);
+static int remoteDispatchStorageVolDownload(
+ struct qemud_server *server,
+ struct qemud_client *client,
+ virConnectPtr conn,
+ remote_message_header *hdr,
+ remote_error *err,
+ remote_storage_vol_download_args *args,
+ void *ret);
static int remoteDispatchStorageVolDumpXml(
struct qemud_server *server,
struct qemud_client *client,
@@ -1586,6 +1594,14 @@ static int remoteDispatchStorageVolLookupByPath(
remote_error *err,
remote_storage_vol_lookup_by_path_args *args,
remote_storage_vol_lookup_by_path_ret *ret);
+static int remoteDispatchStorageVolUpload(
+ struct qemud_server *server,
+ struct qemud_client *client,
+ virConnectPtr conn,
+ remote_message_header *hdr,
+ remote_error *err,
+ remote_storage_vol_upload_args *args,
+ void *ret);
static int remoteDispatchStorageVolWipe(
struct qemud_server *server,
struct qemud_client *client,
diff --git a/daemon/remote_dispatch_table.h b/daemon/remote_dispatch_table.h
index c5f6653..b39f7c2 100644
--- a/daemon/remote_dispatch_table.h
+++ b/daemon/remote_dispatch_table.h
@@ -1042,3 +1042,13 @@
.args_filter = (xdrproc_t) xdr_remote_domain_migrate_set_max_speed_args,
.ret_filter = (xdrproc_t) xdr_void,
},
+{ /* StorageVolUpload => 208 */
+ .fn = (dispatch_fn) remoteDispatchStorageVolUpload,
+ .args_filter = (xdrproc_t) xdr_remote_storage_vol_upload_args,
+ .ret_filter = (xdrproc_t) xdr_void,
+},
+{ /* StorageVolDownload => 209 */
+ .fn = (dispatch_fn) remoteDispatchStorageVolDownload,
+ .args_filter = (xdrproc_t) xdr_remote_storage_vol_download_args,
+ .ret_filter = (xdrproc_t) xdr_void,
+},
diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
index 40da5c2..eaf53ef 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -8484,7 +8484,6 @@ done:
static struct private_stream_data *
remoteStreamOpen(virStreamPtr st,
- int output ATTRIBUTE_UNUSED,
unsigned int proc_nr,
unsigned int serial)
{
@@ -9006,7 +9005,7 @@ remoteDomainMigratePrepareTunnel(virConnectPtr conn,
remoteDriverLock(priv);
- if (!(privst = remoteStreamOpen(st, 1, REMOTE_PROC_DOMAIN_MIGRATE_PREPARE_TUNNEL,
priv->counter)))
+ if (!(privst = remoteStreamOpen(st, REMOTE_PROC_DOMAIN_MIGRATE_PREPARE_TUNNEL,
priv->counter)))
goto done;
st->driver = &remoteStreamDrv;
@@ -9592,6 +9591,91 @@ done:
return rv;
}
+static int
+remoteStorageVolUpload(virStorageVolPtr vol,
+ virStreamPtr st,
+ unsigned long long offset,
+ unsigned long long length,
+ unsigned int flags)
+{
+ struct private_data *priv = vol->conn->privateData;
+ struct private_stream_data *privst = NULL;
+ int rv = -1;
+ remote_storage_vol_upload_args args;
+
+ remoteDriverLock(priv);
+
+ if (!(privst = remoteStreamOpen(st,
+ REMOTE_PROC_STORAGE_VOL_UPLOAD,
+ priv->counter)))
+ goto done;
+
+ st->driver = &remoteStreamDrv;
+ st->privateData = privst;
+
+ make_nonnull_storage_vol(&args.vol, vol);
+ args.offset = offset;
+ args.length = length;
+ args.flags = flags;
+
+ if (call (vol->conn, priv, 0, REMOTE_PROC_STORAGE_VOL_UPLOAD,
+ (xdrproc_t) xdr_remote_storage_vol_upload_args, (char *) &args,
+ (xdrproc_t) xdr_void, NULL) == -1) {
+ remoteStreamRelease(st);
+ goto done;
+ }
+
+ rv = 0;
+
+done:
+ remoteDriverUnlock(priv);
+
+ return rv;
+}
+
+
+static int
+remoteStorageVolDownload(virStorageVolPtr vol,
+ virStreamPtr st,
+ unsigned long long offset,
+ unsigned long long length,
+ unsigned int flags)
+{
+ struct private_data *priv = vol->conn->privateData;
+ struct private_stream_data *privst = NULL;
+ int rv = -1;
+ remote_storage_vol_download_args args;
+
+ remoteDriverLock(priv);
+
+ if (!(privst = remoteStreamOpen(st,
+ REMOTE_PROC_STORAGE_VOL_DOWNLOAD,
+ priv->counter)))
+ goto done;
+
+ st->driver = &remoteStreamDrv;
+ st->privateData = privst;
+
+ make_nonnull_storage_vol(&args.vol, vol);
+ args.offset = offset;
+ args.length = length;
+ args.flags = flags;
+
+ if (call (vol->conn, priv, 0, REMOTE_PROC_STORAGE_VOL_DOWNLOAD,
+ (xdrproc_t) xdr_remote_storage_vol_download_args, (char *) &args,
+ (xdrproc_t) xdr_void, NULL) == -1) {
+ remoteStreamRelease(st);
+ goto done;
+ }
+
+ rv = 0;
+
+done:
+ remoteDriverUnlock(priv);
+
+ return rv;
+}
+
static int
remoteDomainOpenConsole(virDomainPtr dom,
@@ -9606,7 +9690,7 @@ remoteDomainOpenConsole(virDomainPtr dom,
remoteDriverLock(priv);
- if (!(privst = remoteStreamOpen(st, 1, REMOTE_PROC_DOMAIN_OPEN_CONSOLE,
priv->counter)))
+ if (!(privst = remoteStreamOpen(st, REMOTE_PROC_DOMAIN_OPEN_CONSOLE,
priv->counter)))
goto done;
st->driver = &remoteStreamDrv;
@@ -11277,6 +11361,8 @@ static virStorageDriver storage_driver = {
.volLookupByPath = remoteStorageVolLookupByPath,
.volCreateXML = remoteStorageVolCreateXML,
.volCreateXMLFrom = remoteStorageVolCreateXMLFrom,
+ .volDownload = remoteStorageVolDownload,
+ .volUpload = remoteStorageVolUpload,
.volDelete = remoteStorageVolDelete,
.volWipe = remoteStorageVolWipe,
.volGetInfo = remoteStorageVolGetInfo,
diff --git a/src/remote/remote_protocol.c b/src/remote/remote_protocol.c
index 7ecea9d..5604371 100644
--- a/src/remote/remote_protocol.c
+++ b/src/remote/remote_protocol.c
@@ -3872,6 +3872,36 @@ xdr_remote_domain_open_console_args (XDR *xdrs,
remote_domain_open_console_args
}
bool_t
+xdr_remote_storage_vol_upload_args (XDR *xdrs, remote_storage_vol_upload_args *objp)
+{
+
+ if (!xdr_remote_nonnull_storage_vol (xdrs, &objp->vol))
+ return FALSE;
+ if (!xdr_uint64_t (xdrs, &objp->offset))
+ return FALSE;
+ if (!xdr_uint64_t (xdrs, &objp->length))
+ return FALSE;
+ if (!xdr_u_int (xdrs, &objp->flags))
+ return FALSE;
+ return TRUE;
+}
+
+bool_t
+xdr_remote_storage_vol_download_args (XDR *xdrs, remote_storage_vol_download_args *objp)
+{
+
+ if (!xdr_remote_nonnull_storage_vol (xdrs, &objp->vol))
+ return FALSE;
+ if (!xdr_uint64_t (xdrs, &objp->offset))
+ return FALSE;
+ if (!xdr_uint64_t (xdrs, &objp->length))
+ 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 87de0da..d9bf151 100644
--- a/src/remote/remote_protocol.h
+++ b/src/remote/remote_protocol.h
@@ -2184,6 +2184,22 @@ struct remote_domain_open_console_args {
u_int flags;
};
typedef struct remote_domain_open_console_args remote_domain_open_console_args;
+
+struct remote_storage_vol_upload_args {
+ remote_nonnull_storage_vol vol;
+ uint64_t offset;
+ uint64_t length;
+ u_int flags;
+};
+typedef struct remote_storage_vol_upload_args remote_storage_vol_upload_args;
+
+struct remote_storage_vol_download_args {
+ remote_nonnull_storage_vol vol;
+ uint64_t offset;
+ uint64_t length;
+ u_int flags;
+};
+typedef struct remote_storage_vol_download_args remote_storage_vol_download_args;
#define REMOTE_PROGRAM 0x20008086
#define REMOTE_PROTOCOL_VERSION 1
@@ -2395,6 +2411,8 @@ enum remote_procedure {
REMOTE_PROC_DOMAIN_SET_BLKIO_PARAMETERS = 205,
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,
};
typedef enum remote_procedure remote_procedure;
@@ -2776,6 +2794,8 @@ extern bool_t xdr_remote_domain_snapshot_current_ret (XDR *,
remote_domain_snap
extern bool_t xdr_remote_domain_revert_to_snapshot_args (XDR *,
remote_domain_revert_to_snapshot_args*);
extern bool_t xdr_remote_domain_snapshot_delete_args (XDR *,
remote_domain_snapshot_delete_args*);
extern bool_t xdr_remote_domain_open_console_args (XDR *,
remote_domain_open_console_args*);
+extern bool_t xdr_remote_storage_vol_upload_args (XDR *,
remote_storage_vol_upload_args*);
+extern bool_t xdr_remote_storage_vol_download_args (XDR *,
remote_storage_vol_download_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*);
@@ -3131,6 +3151,8 @@ extern bool_t xdr_remote_domain_snapshot_current_ret ();
extern bool_t xdr_remote_domain_revert_to_snapshot_args ();
extern bool_t xdr_remote_domain_snapshot_delete_args ();
extern bool_t xdr_remote_domain_open_console_args ();
+extern bool_t xdr_remote_storage_vol_upload_args ();
+extern bool_t xdr_remote_storage_vol_download_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 7310689..675eccd 100644
--- a/src/remote/remote_protocol.x
+++ b/src/remote/remote_protocol.x
@@ -1926,6 +1926,21 @@ struct remote_domain_open_console_args {
unsigned int flags;
};
+struct remote_storage_vol_upload_args {
+ remote_nonnull_storage_vol vol;
+ unsigned hyper offset;
+ unsigned hyper length;
+ unsigned int flags;
+};
+
+struct remote_storage_vol_download_args {
+ remote_nonnull_storage_vol vol;
+ unsigned hyper offset;
+ unsigned hyper length;
+ unsigned int flags;
+};
+
+
/*----- Protocol. -----*/
/* Define the program number, protocol version and procedure numbers here. */
@@ -2159,7 +2174,9 @@ enum remote_procedure {
REMOTE_PROC_DOMAIN_SET_MEMORY_FLAGS = 204,
REMOTE_PROC_DOMAIN_SET_BLKIO_PARAMETERS = 205,
REMOTE_PROC_DOMAIN_GET_BLKIO_PARAMETERS = 206,
- REMOTE_PROC_DOMAIN_MIGRATE_SET_MAX_SPEED = 207
+ REMOTE_PROC_DOMAIN_MIGRATE_SET_MAX_SPEED = 207,
+ REMOTE_PROC_STORAGE_VOL_UPLOAD = 208,
+ REMOTE_PROC_STORAGE_VOL_DOWNLOAD = 209
/*
* Notice how the entries are grouped in sets of 10 ?
diff --git a/src/remote_protocol-structs b/src/remote_protocol-structs
index 81889c3..7dabb33 100644
--- a/src/remote_protocol-structs
+++ b/src/remote_protocol-structs
@@ -1414,6 +1414,18 @@ struct remote_domain_open_console_args {
remote_string devname;
u_int flags;
};
+struct remote_storage_vol_upload_args {
+ remote_nonnull_storage_vol vol;
+ uint64_t offset;
+ uint64_t length;
+ u_int flags;
+};
+struct remote_storage_vol_download_args {
+ remote_nonnull_storage_vol vol;
+ uint64_t offset;
+ uint64_t length;
+ u_int flags;
+};
struct remote_message_header {
u_int prog;
u_int vers;
--
1.7.4