[libvirt] [PATCH 3/4] vcpupin: implement the remote protocol to address the new API
Hu Tao
hutao at cn.fujitsu.com
Fri Apr 1 08:44:21 UTC 2011
On Thu, Mar 31, 2011 at 02:39:52PM +0900, Taku Izumi wrote:
>
> This patch implements the remote protocol to address the new API
> (virDomainPinVcpuFlags).
>
> Signed-off-by: Taku Izumi <izumi.taku at jp.fujitsu.com>
> ---
> daemon/remote.c | 37 +++++++++++++++++++++++++++++++++
> daemon/remote_dispatch_args.h | 1
> daemon/remote_dispatch_prototypes.h | 8 +++++++
> daemon/remote_dispatch_table.h | 5 ++++
> src/remote/remote_driver.c | 40 +++++++++++++++++++++++++++++++++++-
> src/remote/remote_protocol.c | 16 ++++++++++++++
> src/remote/remote_protocol.h | 14 ++++++++++++
> src/remote/remote_protocol.x | 10 ++++++++-
> src/remote_protocol-structs | 9 ++++++++
> 9 files changed, 138 insertions(+), 2 deletions(-)
>
> Index: libvirt/daemon/remote.c
> ===================================================================
> --- libvirt.orig/daemon/remote.c
> +++ libvirt/daemon/remote.c
> @@ -2188,6 +2188,43 @@ remoteDispatchDomainPinVcpu (struct qemu
> }
>
> static int
> +remoteDispatchDomainPinVcpuFlags (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_pin_vcpu_flags_args *args,
> + void *ret ATTRIBUTE_UNUSED)
> +{
> + virDomainPtr dom;
> + int rv;
> +
> + dom = get_nonnull_domain (conn, args->dom);
> + if (dom == NULL) {
> + remoteDispatchConnError(rerr, conn);
> + return -1;
> + }
> +
> + if (args->cpumap.cpumap_len > REMOTE_CPUMAP_MAX) {
> + virDomainFree(dom);
> + remoteDispatchFormatError (rerr, "%s", _("cpumap_len > REMOTE_CPUMAP_MAX"));
> + return -1;
> + }
> +
> + rv = virDomainPinVcpuFlags (dom, args->vcpu,
> + (unsigned char *) args->cpumap.cpumap_val,
> + args->cpumap.cpumap_len,
> + args->flags);
> + if (rv == -1) {
> + remoteDispatchConnError(rerr, conn);
> + virDomainFree(dom);
> + return -1;
> + }
> + virDomainFree(dom);
> + return 0;
> +}
> +
> +static int
> remoteDispatchDomainReboot (struct qemud_server *server ATTRIBUTE_UNUSED,
> struct qemud_client *client ATTRIBUTE_UNUSED,
> virConnectPtr conn,
> Index: libvirt/daemon/remote_dispatch_args.h
> ===================================================================
> --- libvirt.orig/daemon/remote_dispatch_args.h
> +++ libvirt/daemon/remote_dispatch_args.h
> @@ -178,3 +178,4 @@
> remote_domain_migrate_set_max_speed_args
> val_remote_domain_migrate_set_max_speed_args;
Long line auto-wrapped by your mail client?
> remote_storage_vol_upload_args val_remote_storage_vol_upload_args;
> remote_storage_vol_download_args val_remote_storage_vol_download_args;
> + remote_domain_pin_vcpu_flags_args val_remote_domain_pin_vcpu_flags_args;
> Index: libvirt/daemon/remote_dispatch_prototypes.h
> ===================================================================
> --- libvirt.orig/daemon/remote_dispatch_prototypes.h
> +++ libvirt/daemon/remote_dispatch_prototypes.h
> @@ -506,6 +506,14 @@ static int remoteDispatchDomainPinVcpu(
> remote_error *err,
> remote_domain_pin_vcpu_args *args,
> void *ret);
> +static int remoteDispatchDomainPinVcpuFlags(
> + struct qemud_server *server,
> + struct qemud_client *client,
> + virConnectPtr conn,
> + remote_message_header *hdr,
> + remote_error *err,
> + remote_domain_pin_vcpu_flags_args *args,
> + void *ret);
> static int remoteDispatchDomainReboot(
> struct qemud_server *server,
> struct qemud_client *client,
> Index: libvirt/daemon/remote_dispatch_table.h
> ===================================================================
> --- libvirt.orig/daemon/remote_dispatch_table.h
> +++ libvirt/daemon/remote_dispatch_table.h
> @@ -1052,3 +1052,8 @@
> .args_filter = (xdrproc_t) xdr_remote_storage_vol_download_args,
> .ret_filter = (xdrproc_t) xdr_void,
> },
> +{ /* DomainPinVcpuFlags => 210 */
> + .fn = (dispatch_fn) remoteDispatchDomainPinVcpuFlags,
> + .args_filter = (xdrproc_t) xdr_remote_domain_pin_vcpu_flags_args,
> + .ret_filter = (xdrproc_t) xdr_void,
> +},
> Index: libvirt/src/remote/remote_driver.c
> ===================================================================
> --- libvirt.orig/src/remote/remote_driver.c
> +++ libvirt/src/remote/remote_driver.c
> @@ -3042,6 +3042,44 @@ done:
> }
>
> static int
> +remoteDomainPinVcpuFlags (virDomainPtr domain,
> + unsigned int vcpu,
> + unsigned char *cpumap,
> + int maplen,
> + unsigned int flags)
> +{
> + int rv = -1;
> + remote_domain_pin_vcpu_flags_args args;
> + struct private_data *priv = domain->conn->privateData;
> +
> + remoteDriverLock(priv);
> +
> + if (maplen > REMOTE_CPUMAP_MAX) {
> + remoteError(VIR_ERR_RPC,
> + _("map length greater than maximum: %d > %d"),
> + maplen, REMOTE_CPUMAP_MAX);
> + goto done;
> + }
> +
> + make_nonnull_domain (&args.dom, domain);
> + args.vcpu = vcpu;
> + args.cpumap.cpumap_len = maplen;
> + args.cpumap.cpumap_val = (char *) cpumap;
> + args.flags = flags;
> +
> + if (call (domain->conn, priv, 0, REMOTE_PROC_DOMAIN_PIN_VCPU_FLAGS,
> + (xdrproc_t) xdr_remote_domain_pin_vcpu_flags_args, (char *) &args,
> + (xdrproc_t) xdr_void, (char *) NULL) == -1)
> + goto done;
> +
> + rv = 0;
> +
> +done:
> + remoteDriverUnlock(priv);
> + return rv;
> +}
> +
> +static int
> remoteDomainGetVcpus (virDomainPtr domain,
> virVcpuInfoPtr info,
> int maxinfo,
> @@ -11227,7 +11265,7 @@ static virDriver remote_driver = {
> remoteDomainSetVcpusFlags, /* domainSetVcpusFlags */
> remoteDomainGetVcpusFlags, /* domainGetVcpusFlags */
> remoteDomainPinVcpu, /* domainPinVcpu */
> - NULL, /* domainPinVcpuFlags */
> + remoteDomainPinVcpuFlags, /* domainPinVcpuFlags */
> remoteDomainGetVcpus, /* domainGetVcpus */
> remoteDomainGetMaxVcpus, /* domainGetMaxVcpus */
> remoteDomainGetSecurityLabel, /* domainGetSecurityLabel */
> Index: libvirt/src/remote/remote_protocol.c
> ===================================================================
> --- libvirt.orig/src/remote/remote_protocol.c
> +++ libvirt/src/remote/remote_protocol.c
> @@ -1521,6 +1521,22 @@ xdr_remote_domain_pin_vcpu_args (XDR *xd
> }
>
> bool_t
> +xdr_remote_domain_pin_vcpu_flags_args (XDR *xdrs, remote_domain_pin_vcpu_flags_args
> *objp)
Long line auto-wrapped by your mail client?
> +{
> + char **objp_cpp0 = (char **) (void *) &objp->cpumap.cpumap_val;
> +
> + if (!xdr_remote_nonnull_domain (xdrs, &objp->dom))
> + return FALSE;
> + if (!xdr_int (xdrs, &objp->vcpu))
> + return FALSE;
> + if (!xdr_bytes (xdrs, objp_cpp0, (u_int *) &objp->cpumap.cpumap_len,
> REMOTE_CPUMAP_MAX))
Long line auto-wrapped by your mail client?
> + return FALSE;
> + if (!xdr_u_int (xdrs, &objp->flags))
> + return FALSE;
> + return TRUE;
> +}
> +
> +bool_t
> xdr_remote_domain_get_vcpus_args (XDR *xdrs, remote_domain_get_vcpus_args *objp)
> {
>
> Index: libvirt/src/remote/remote_protocol.h
> ===================================================================
> --- libvirt.orig/src/remote/remote_protocol.h
> +++ libvirt/src/remote/remote_protocol.h
> @@ -841,6 +841,17 @@ struct remote_domain_pin_vcpu_args {
> };
> typedef struct remote_domain_pin_vcpu_args remote_domain_pin_vcpu_args;
>
> +struct remote_domain_pin_vcpu_flags_args {
> + remote_nonnull_domain dom;
> + int vcpu;
> + struct {
> + u_int cpumap_len;
> + char *cpumap_val;
> + } cpumap;
> + u_int flags;
> +};
> +typedef struct remote_domain_pin_vcpu_flags_args remote_domain_pin_vcpu_flags_args;
> +
> struct remote_domain_get_vcpus_args {
> remote_nonnull_domain dom;
> int maxinfo;
> @@ -2413,6 +2424,7 @@ 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_PIN_VCPU_FLAGS = 210,
> };
> typedef enum remote_procedure remote_procedure;
>
> @@ -2566,6 +2578,7 @@ extern bool_t xdr_remote_domain_set_vcp
> extern bool_t xdr_remote_domain_get_vcpus_flags_args (XDR *,
> remote_domain_get_vcpus_flags_args*);
Long line auto-wrapped by your mail client?
> extern bool_t xdr_remote_domain_get_vcpus_flags_ret (XDR *,
> remote_domain_get_vcpus_flags_ret*);
Long line auto-wrapped by your mail client?
> extern bool_t xdr_remote_domain_pin_vcpu_args (XDR *, remote_domain_pin_vcpu_args*);
> +extern bool_t xdr_remote_domain_pin_vcpu_flags_args (XDR *,
> remote_domain_pin_vcpu_flags_args*);
Long line auto-wrapped by your mail client?
> extern bool_t xdr_remote_domain_get_vcpus_args (XDR *, remote_domain_get_vcpus_args*);
> extern bool_t xdr_remote_domain_get_vcpus_ret (XDR *, remote_domain_get_vcpus_ret*);
> extern bool_t xdr_remote_domain_get_max_vcpus_args (XDR *,
> remote_domain_get_max_vcpus_args*);
Long line auto-wrapped by your mail client?
> @@ -2923,6 +2936,7 @@ extern bool_t xdr_remote_domain_set_vcpu
> extern bool_t xdr_remote_domain_get_vcpus_flags_args ();
> extern bool_t xdr_remote_domain_get_vcpus_flags_ret ();
> extern bool_t xdr_remote_domain_pin_vcpu_args ();
> +extern bool_t xdr_remote_domain_pin_vcpu_flags_args ();
> extern bool_t xdr_remote_domain_get_vcpus_args ();
> extern bool_t xdr_remote_domain_get_vcpus_ret ();
> extern bool_t xdr_remote_domain_get_max_vcpus_args ();
> Index: libvirt/src/remote/remote_protocol.x
> ===================================================================
> --- libvirt.orig/src/remote/remote_protocol.x
> +++ libvirt/src/remote/remote_protocol.x
> @@ -843,6 +843,13 @@ struct remote_domain_pin_vcpu_args {
> opaque cpumap<REMOTE_CPUMAP_MAX>;
> };
>
> +struct remote_domain_pin_vcpu_flags_args {
> + remote_nonnull_domain dom;
> + int vcpu;
> + opaque cpumap<REMOTE_CPUMAP_MAX>;
> + unsigned int flags;
> +};
> +
> struct remote_domain_get_vcpus_args {
> remote_nonnull_domain dom;
> int maxinfo;
> @@ -2176,7 +2183,8 @@ 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_PIN_VCPU_FLAGS = 210
>
> /*
> * Notice how the entries are grouped in sets of 10 ?
> Index: libvirt/src/remote_protocol-structs
> ===================================================================
> --- libvirt.orig/src/remote_protocol-structs
> +++ libvirt/src/remote_protocol-structs
> @@ -528,6 +528,15 @@ struct remote_domain_pin_vcpu_args {
> char * cpumap_val;
> } cpumap;
> };
> +struct remote_domain_pin_vcpu_flags_args {
> + remote_nonnull_domain dom;
> + int vcpu;
> + struct {
> + u_int cpumap_len;
> + char * cpumap_val;
> + } cpumap;
> + u_int flags;
> +};
> struct remote_domain_get_vcpus_args {
> remote_nonnull_domain dom;
> int maxinfo;
>
>
> --
> libvir-list mailing list
> libvir-list at redhat.com
> https://www.redhat.com/mailman/listinfo/libvir-list
More information about the libvir-list
mailing list