mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 13:45:38 +00:00
Remote protocol support for storage vol upload/download APIs
* 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
This commit is contained in:
parent
925639627c
commit
230a5d8b4a
@ -5831,7 +5831,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;
|
||||
}
|
||||
|
||||
|
||||
/***************************
|
||||
|
@ -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;
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
},
|
||||
|
@ -8494,7 +8494,6 @@ done:
|
||||
|
||||
static struct private_stream_data *
|
||||
remoteStreamOpen(virStreamPtr st,
|
||||
int output ATTRIBUTE_UNUSED,
|
||||
unsigned int proc_nr,
|
||||
unsigned int serial)
|
||||
{
|
||||
@ -9016,7 +9015,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;
|
||||
@ -9602,6 +9601,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,
|
||||
@ -9616,7 +9700,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;
|
||||
@ -11287,6 +11371,8 @@ static virStorageDriver storage_driver = {
|
||||
.volLookupByPath = remoteStorageVolLookupByPath,
|
||||
.volCreateXML = remoteStorageVolCreateXML,
|
||||
.volCreateXMLFrom = remoteStorageVolCreateXMLFrom,
|
||||
.volDownload = remoteStorageVolDownload,
|
||||
.volUpload = remoteStorageVolUpload,
|
||||
.volDelete = remoteStorageVolDelete,
|
||||
.volWipe = remoteStorageVolWipe,
|
||||
.volGetInfo = remoteStorageVolGetInfo,
|
||||
|
@ -3871,6 +3871,36 @@ xdr_remote_domain_open_console_args (XDR *xdrs, remote_domain_open_console_args
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
|
@ -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 ();
|
||||
|
@ -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 ?
|
||||
|
@ -1415,6 +1415,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;
|
||||
|
Loading…
Reference in New Issue
Block a user