mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06: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:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
/***************************
|
||||
|
||||
Reference in New Issue
Block a user