Implement the remote plumbing to get an IOThread's pinned CPU data or to allow pinning an IOThread to a specific CPU set Signed-off-by: John Ferlan <jferlan@xxxxxxxxxx> --- daemon/remote.c | 49 ++++++++++++++++++++++++++++++++++ src/remote/remote_driver.c | 62 ++++++++++++++++++++++++++++++++++++++++++++ src/remote/remote_protocol.x | 35 ++++++++++++++++++++++++- src/remote_protocol-structs | 24 +++++++++++++++++ src/rpc/gendispatch.pl | 1 + 5 files changed, 170 insertions(+), 1 deletion(-) diff --git a/daemon/remote.c b/daemon/remote.c index ff64eeb..8907b7e 100644 --- a/daemon/remote.c +++ b/daemon/remote.c @@ -2341,6 +2341,55 @@ remoteDispatchDomainGetIOThreadsInfo(virNetServerPtr server ATTRIBUTE_UNUSED, } static int +remoteDispatchDomainGetIOThreadPin(virNetServerPtr server ATTRIBUTE_UNUSED, + virNetServerClientPtr client ATTRIBUTE_UNUSED, + virNetMessagePtr msg ATTRIBUTE_UNUSED, + virNetMessageErrorPtr rerr, + remote_domain_get_iothread_pin_args *args, + remote_domain_get_iothread_pin_ret *ret) +{ + virDomainPtr dom = NULL; + unsigned char *cpumap = NULL; + int r; + int rv = -1; + struct daemonClientPrivate *priv = + virNetServerClientGetPrivateData(client); + + if (!priv->conn) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open")); + goto cleanup; + } + + if (!(dom = get_nonnull_domain(priv->conn, args->dom))) + goto cleanup; + + /* Allocate buffers to take the results */ + if (args->maplen > 0 && + VIR_ALLOC_N(cpumap, args->maplen) < 0) + goto cleanup; + + if ((r = virDomainGetIOThreadPin(dom, + args->iothread_id, + cpumap, + args->maplen, + args->flags)) < 0) + goto cleanup; + + ret->ret = r; + ret->cpumap.cpumap_len = args->maplen; + ret->cpumap.cpumap_val = (char *) cpumap; + cpumap = NULL; + + rv = 0; + + cleanup: + if (rv < 0) + virNetMessageSaveError(rerr); + VIR_FREE(cpumap); + virObjectUnref(dom); + return rv; +} +static int remoteDispatchDomainMigratePrepare(virNetServerPtr server ATTRIBUTE_UNUSED, virNetServerClientPtr client ATTRIBUTE_UNUSED, virNetMessagePtr msg ATTRIBUTE_UNUSED, diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c index 42dab9d..fa99a31 100644 --- a/src/remote/remote_driver.c +++ b/src/remote/remote_driver.c @@ -2394,6 +2394,66 @@ remoteDomainGetIOThreadsInfo(virDomainPtr dom, } static int +remoteDomainGetIOThreadPin(virDomainPtr domain, + unsigned int iothread_id, + unsigned char *cpumap, + int maplen, + unsigned int flags) +{ + int rv = -1; + size_t i; + remote_domain_get_iothread_pin_args args; + remote_domain_get_iothread_pin_ret ret; + struct private_data *priv = domain->conn->privateData; + + remoteDriverLock(priv); + + /* There is only one cpumap for each IOThread thread */ + if (maplen > REMOTE_CPUMAPS_MAX) { + virReportError(VIR_ERR_RPC, + _("IOThread map buffer length exceeds maximum: %d > %d"), + maplen, REMOTE_CPUMAPS_MAX); + goto done; + } + + make_nonnull_domain(&args.dom, domain); + args.iothread_id = iothread_id; + args.maplen = maplen; + args.flags = flags; + + memset(&ret, 0, sizeof(ret)); + + if (call(domain->conn, priv, 0, REMOTE_PROC_DOMAIN_GET_IOTHREAD_PIN, + (xdrproc_t) xdr_remote_domain_get_iothread_pin_args, + (char *) &args, + (xdrproc_t) xdr_remote_domain_get_iothread_pin_ret, + (char *) &ret) == -1) + goto done; + + if (ret.cpumap.cpumap_len > maplen) { + virReportError(VIR_ERR_RPC, + _("host reports map buffer length exceeds maximum: %d > %d"), + ret.cpumap.cpumap_len, maplen); + goto cleanup; + } + + memset(cpumap, 0, maplen); + + for (i = 0; i < ret.cpumap.cpumap_len; ++i) + cpumap[i] = ret.cpumap.cpumap_val[i]; + + rv = ret.ret; + + cleanup: + xdr_free((xdrproc_t) xdr_remote_domain_get_iothread_pin_ret, + (char *) &ret); + + done: + remoteDriverUnlock(priv); + return rv; +} + +static int remoteDomainGetSecurityLabel(virDomainPtr domain, virSecurityLabelPtr seclabel) { remote_domain_get_security_label_args args; @@ -8106,6 +8166,8 @@ static virHypervisorDriver hypervisor_driver = { .domainGetVcpus = remoteDomainGetVcpus, /* 0.3.0 */ .domainGetMaxVcpus = remoteDomainGetMaxVcpus, /* 0.3.0 */ .domainGetIOThreadsInfo = remoteDomainGetIOThreadsInfo, /* 1.2.14 */ + .domainGetIOThreadPin = remoteDomainGetIOThreadPin, /* 1.2.14 */ + .domainPinIOThread = remoteDomainPinIOThread, /* 1.2.14 */ .domainGetSecurityLabel = remoteDomainGetSecurityLabel, /* 0.6.1 */ .domainGetSecurityLabelList = remoteDomainGetSecurityLabelList, /* 0.10.0 */ .nodeGetSecurityModel = remoteNodeGetSecurityModel, /* 0.6.1 */ diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x index 4ea535e..dc916f3 100644 --- a/src/remote/remote_protocol.x +++ b/src/remote/remote_protocol.x @@ -1199,6 +1199,25 @@ struct remote_domain_get_iothreads_info_ret { unsigned int ret; }; +struct remote_domain_get_iothread_pin_args { + remote_nonnull_domain dom; + unsigned int iothread_id; + int maplen; + unsigned int flags; +}; + +struct remote_domain_get_iothread_pin_ret { + opaque cpumap<REMOTE_CPUMAPS_MAX>; + int ret; +}; + +struct remote_domain_pin_iothread_args { + remote_nonnull_domain dom; + unsigned int iothreads_id; + opaque cpumap<REMOTE_CPUMAP_MAX>; /* (unsigned char *) */ + unsigned int flags; +}; + struct remote_domain_get_security_label_args { remote_nonnull_domain dom; }; @@ -5593,5 +5612,19 @@ enum remote_procedure { * @generate: none * @acl: domain:read */ - REMOTE_PROC_DOMAIN_GET_IOTHREADS_INFO = 351 + REMOTE_PROC_DOMAIN_GET_IOTHREADS_INFO = 351, + + /** + * @generate: none + * @acl: domain:read + */ + REMOTE_PROC_DOMAIN_GET_IOTHREAD_PIN = 352, + + /** + * @generate: both + * @acl: domain:write + * @acl: domain:save:!VIR_DOMAIN_AFFECT_CONFIG|VIR_DOMAIN_AFFECT_LIVE + * @acl: domain:save:VIR_DOMAIN_AFFECT_CONFIG + */ + REMOTE_PROC_DOMAIN_PIN_IOTHREAD = 353 }; diff --git a/src/remote_protocol-structs b/src/remote_protocol-structs index 907bcd4..4fa710c 100644 --- a/src/remote_protocol-structs +++ b/src/remote_protocol-structs @@ -825,6 +825,28 @@ struct remote_domain_get_iothreads_info_ret { } info; u_int ret; }; +struct remote_domain_get_iothread_pin_args { + remote_nonnull_domain dom; + u_int iothread_id; + int maplen; + u_int flags; +}; +struct remote_domain_get_iothread_pin_ret { + struct { + u_int cpumap_len; + char * cpumap_val; + } cpumap; + int ret; +}; +struct remote_domain_pin_iothread_args { + remote_nonnull_domain dom; + u_int iothreads_id; + struct { + u_int cpumap_len; + char * cpumap_val; + } cpumap; + u_int flags; +}; struct remote_domain_get_security_label_args { remote_nonnull_domain dom; }; @@ -2982,4 +3004,6 @@ enum remote_procedure { REMOTE_PROC_DOMAIN_GET_FSINFO = 349, REMOTE_PROC_DOMAIN_DEFINE_XML_FLAGS = 350, REMOTE_PROC_DOMAIN_GET_IOTHREADS_INFO = 351, + REMOTE_PROC_DOMAIN_GET_IOTHREAD_PIN = 352, + REMOTE_PROC_DOMAIN_PIN_IOTHREAD = 353, }; diff --git a/src/rpc/gendispatch.pl b/src/rpc/gendispatch.pl index 78cb415..8b488eb 100755 --- a/src/rpc/gendispatch.pl +++ b/src/rpc/gendispatch.pl @@ -68,6 +68,7 @@ sub fixup_name { $name =~ s/Fsthaw$/FSThaw/; $name =~ s/Fsinfo$/FSInfo/; $name =~ s/Iothreads$/IOThreads/; + $name =~ s/Iothread$/IOThread/; $name =~ s/Scsi/SCSI/; $name =~ s/Wwn$/WWN/; $name =~ s/Dhcp$/DHCP/; -- 2.1.0 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list