[libvirt] [PATCH] Regression: Report correct CPUs present on executing virsh nodecpumap
by Nitesh Konkar
Recent changes to virbitmap.c file created a regression
where on executing the virsh nodecpumap command, the number
of CPUs present was shown as (last cpu online id + 1). This
patch fixes the issue.
Signed-off-by: Nitesh Konkar <nitkon12(a)linux.vnet.ibm.com>
---
src/Makefile.am | 2 ++
src/util/virbitmap.c | 10 ++++++++--
2 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/src/Makefile.am b/src/Makefile.am
index f95f30e2f..96c541c9c 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -3303,6 +3303,8 @@ libvirt_nss_la_SOURCES = \
util/viratomic.h \
util/virbitmap.c \
util/virbitmap.h \
+ util/virhostcpu.c \
+ util/virhostcpu.h \
util/virbuffer.c \
util/virbuffer.h \
util/vircommand.c \
diff --git a/src/util/virbitmap.c b/src/util/virbitmap.c
index eac63d997..dc427f430 100644
--- a/src/util/virbitmap.c
+++ b/src/util/virbitmap.c
@@ -37,6 +37,7 @@
#include "count-one-bits.h"
#include "virstring.h"
#include "virerror.h"
+#include "virhostcpu.h"
#define VIR_FROM_THIS VIR_FROM_NONE
@@ -565,9 +566,14 @@ virBitmapParseUnlimited(const char *str)
const char *cur = str;
char *tmp;
size_t i;
- int start, last;
+ int start, last, bitmapSize;
+
+ bitmapSize = virHostCPUGetCount();
+
+ if (bitmapSize < 0)
+ return NULL;
- if (!(bitmap = virBitmapNewEmpty()))
+ if (!(bitmap = virBitmapNew(bitmapSize)))
return NULL;
if (!str)
--
2.11.0
7 years, 6 months
[libvirt] [PATCH v2] lib: Add note that bulk stats API queries may overrun RPC buffers
by Peter Krempa
Hint that the users should limit the number of VMs queried in the bulk
stats API.
---
v2:
- added a suggestion of the number of queried VMs (valid after bump to 32M message)
src/libvirt-domain.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c
index 310b91b37..aef061943 100644
--- a/src/libvirt-domain.c
+++ b/src/libvirt-domain.c
@@ -11315,6 +11315,10 @@ virConnectGetDomainCapabilities(virConnectPtr conn,
* VIR_CONNECT_GET_ALL_DOMAINS_STATS_SHUTOFF and/or
* VIR_CONNECT_GET_ALL_DOMAINS_STATS_OTHER for all other states.
*
+ * Note that this API is prone to exceeding maximum RPC message size on hosts
+ * with lots of VMs so it's suggested to use virDomainListGetStats with a
+ * reasonable list of VMs as the argument.
+ *
* Returns the count of returned statistics structures on success, -1 on error.
* The requested data are returned in the @retStats parameter. The returned
* array should be freed by the caller. See virDomainStatsRecordListFree.
@@ -11386,6 +11390,10 @@ virConnectGetAllDomainStats(virConnectPtr conn,
* Note that any of the domain list filtering flags in @flags may be rejected
* by this function.
*
+ * Note that this API is prone to exceeding maximum RPC if querying too many VMs
+ * with lots of statistics. It's suggested to query in batches of 10VMs, which
+ * should be good enough for VMs with 3000 disks + networks.
+ *
* Returns the count of returned statistics structures on success, -1 on error.
* The requested data are returned in the @retStats parameter. The returned
* array should be freed by the caller. See virDomainStatsRecordListFree.
--
2.12.2
7 years, 6 months
[libvirt] [V4 RESEND PATCH] Expose resource control capabilites on cache bank
by Eli Qiao
* This patch amends the cache bank capability as follow:
<cache>
<bank id='0' level='3' type='unified' size='15360' unit='KiB' cpus='0-5'>
<control min='768' unit='KiB' scope='both' max_allocation='4'/>
</bank>
<bank id='1' level='3' type='unified' size='15360' unit='KiB' cpus='6-11'>
<control min='768' unit='KiB' scope='both' max_allocation='4'/>
</bank>
</cache>
For CDP enabled on x86 arch, we will have:
<cache>
<bank id='0' level='3' type='unified' size='15360' unit='KiB' cpus='0-5'>
<control min='768' unit='KiB' scope='code' max_allocation='4'/>
<control min='768' unit='KiB' scope='data' max_allocation='4'/>
</bank>
...
* Added a new testdata directory `linux-resctrl-cdp` to test CDP enabled
case.
* Along with vircaps2xmltest case updated.
Signed-off-by: Eli Qiao <liyong.qiao(a)intel.com>
---
docs/schemas/capability.rng | 20 +++
src/conf/capabilities.c | 138 ++++++++++++++++++++-
src/conf/capabilities.h | 12 ++
.../vircaps2xmldata/linux-resctrl-cdp/resctrl/cpus | 1 +
.../linux-resctrl-cdp/resctrl/info/L3CODE/cbm_mask | 1 +
.../resctrl/info/L3CODE/min_cbm_bits | 1 +
.../resctrl/info/L3CODE/num_closids | 1 +
.../linux-resctrl-cdp/resctrl/info/L3DATA/cbm_mask | 1 +
.../resctrl/info/L3DATA/min_cbm_bits | 1 +
.../resctrl/info/L3DATA/num_closids | 1 +
.../linux-resctrl-cdp/resctrl/manualres/cpus | 1 +
.../linux-resctrl-cdp/resctrl/manualres/schemata | 2 +
.../linux-resctrl-cdp/resctrl/manualres/tasks | 0
.../linux-resctrl-cdp/resctrl/schemata | 2 +
.../linux-resctrl-cdp/resctrl/tasks | 0
tests/vircaps2xmldata/linux-resctrl-cdp/system | 1 +
.../vircaps2xmldata/vircaps-x86_64-resctrl-cdp.xml | 55 ++++++++
tests/vircaps2xmldata/vircaps-x86_64-resctrl.xml | 8 +-
tests/vircaps2xmltest.c | 10 +-
19 files changed, 252 insertions(+), 4 deletions(-)
create mode 100644 tests/vircaps2xmldata/linux-resctrl-cdp/resctrl/cpus
create mode 100755 tests/vircaps2xmldata/linux-resctrl-cdp/resctrl/info/L3CODE/cbm_mask
create mode 100755 tests/vircaps2xmldata/linux-resctrl-cdp/resctrl/info/L3CODE/min_cbm_bits
create mode 100755 tests/vircaps2xmldata/linux-resctrl-cdp/resctrl/info/L3CODE/num_closids
create mode 100755 tests/vircaps2xmldata/linux-resctrl-cdp/resctrl/info/L3DATA/cbm_mask
create mode 100755 tests/vircaps2xmldata/linux-resctrl-cdp/resctrl/info/L3DATA/min_cbm_bits
create mode 100755 tests/vircaps2xmldata/linux-resctrl-cdp/resctrl/info/L3DATA/num_closids
create mode 100644 tests/vircaps2xmldata/linux-resctrl-cdp/resctrl/manualres/cpus
create mode 100644 tests/vircaps2xmldata/linux-resctrl-cdp/resctrl/manualres/schemata
create mode 100644 tests/vircaps2xmldata/linux-resctrl-cdp/resctrl/manualres/tasks
create mode 100644 tests/vircaps2xmldata/linux-resctrl-cdp/resctrl/schemata
create mode 100644 tests/vircaps2xmldata/linux-resctrl-cdp/resctrl/tasks
create mode 120000 tests/vircaps2xmldata/linux-resctrl-cdp/system
create mode 100644 tests/vircaps2xmldata/vircaps-x86_64-resctrl-cdp.xml
diff --git a/docs/schemas/capability.rng b/docs/schemas/capability.rng
index 26f0aa2..927fc18 100644
--- a/docs/schemas/capability.rng
+++ b/docs/schemas/capability.rng
@@ -277,6 +277,26 @@
<attribute name='cpus'>
<ref name='cpuset'/>
</attribute>
+ <zeroOrMore>
+ <element name='control'>
+ <attribute name='min'>
+ <ref name='unsignedInt'/>
+ </attribute>
+ <attribute name='unit'>
+ <ref name='unit'/>
+ </attribute>
+ <attribute name='scope'>
+ <choice>
+ <value>both</value>
+ <value>code</value>
+ <value>data</value>
+ </choice>
+ </attribute>
+ <attribute name='max_allocation'>
+ <ref name='unsignedInt'/>
+ </attribute>
+ </element>
+ </zeroOrMore>
</element>
</oneOrMore>
</element>
diff --git a/src/conf/capabilities.c b/src/conf/capabilities.c
index a91a72a..0888605 100644
--- a/src/conf/capabilities.c
+++ b/src/conf/capabilities.c
@@ -51,6 +51,7 @@
#define VIR_FROM_THIS VIR_FROM_CAPABILITIES
#define SYSFS_SYSTEM_PATH "/sys/devices/system"
+#define SYSFS_RESCTRL_PATH "/sys/fs/resctrl"
VIR_LOG_INIT("conf.capabilities")
@@ -872,6 +873,9 @@ virCapabilitiesFormatCaches(virBufferPtr buf,
virCapsHostCacheBankPtr *caches)
{
size_t i = 0;
+ size_t j = 0;
+ int indent = virBufferGetIndent(buf, false);
+ virBuffer controlBuf = VIR_BUFFER_INITIALIZER;
if (!ncaches)
return 0;
@@ -893,13 +897,35 @@ virCapabilitiesFormatCaches(virBufferPtr buf,
*/
virBufferAsprintf(buf,
"<bank id='%u' level='%u' type='%s' "
- "size='%llu' unit='%s' cpus='%s'/>\n",
+ "size='%llu' unit='%s' cpus='%s'",
bank->id, bank->level,
virCacheTypeToString(bank->type),
bank->size >> (kilos * 10),
kilos ? "KiB" : "B",
cpus_str);
+ virBufferAdjustIndent(&controlBuf, indent + 4);
+ for (j = 0; j < bank->ncontrols; j++) {
+ bool min_kilos = !(bank->controls[j]->min % 1024);
+ virBufferAsprintf(&controlBuf,
+ "<control min='%llu' unit='%s' "
+ "scope='%s' max_allocation='%u'/>\n",
+ bank->controls[j]->min >> (min_kilos * 10),
+ min_kilos ? "KiB" : "B",
+ virCacheTypeToString(bank->controls[j]->scope),
+ bank->controls[j]->max_allocation);
+ }
+
+ if (virBufferUse(&controlBuf)) {
+ virBufferAddLit(buf, ">\n");
+ virBufferAddBuffer(buf, &controlBuf);
+ virBufferAddLit(buf, "</bank>\n");
+
+ } else {
+ virBufferAddLit(buf, "/>\n");
+ }
+
+ virBufferFreeAndReset(&controlBuf);
VIR_FREE(cpus_str);
}
@@ -1519,13 +1545,102 @@ virCapsHostCacheBankEquals(virCapsHostCacheBankPtr a,
void
virCapsHostCacheBankFree(virCapsHostCacheBankPtr ptr)
{
+ size_t i;
+
if (!ptr)
return;
virBitmapFree(ptr->cpus);
+ for (i = 0; i < ptr->ncontrols; i++)
+ VIR_FREE(ptr->controls[i]);
+ VIR_FREE(ptr->controls);
VIR_FREE(ptr);
}
+/* test which TYPE of cache control supported
+ * -1: don't support
+ * 0: cat
+ * 1: cdp
+ */
+static int
+virCapabilitiesGetCacheControlType(virCapsHostCacheBankPtr bank)
+{
+ int ret = -1;
+ char *path = NULL;
+ if (virAsprintf(&path,
+ SYSFS_RESCTRL_PATH "/info/L%u",
+ bank->level) < 0)
+ return -1;
+
+ if (virFileExists(path)) {
+ ret = 0;
+ } else {
+ VIR_FREE(path);
+ /* for CDP enabled case, CODE and DATA will show together */
+ if (virAsprintf(&path,
+ SYSFS_RESCTRL_PATH "/info/L%uCODE",
+ bank->level) < 0)
+ return -1;
+ if (virFileExists(path))
+ ret = 1;
+ }
+
+ VIR_FREE(path);
+ return ret;
+}
+
+static int
+virCapabilitiesGetCacheControl(virCapsHostCacheBankPtr bank,
+ virCacheType scope)
+{
+ int ret = -1;
+ char *path = NULL;
+ char *cbm_mask = NULL;
+ char *type_upper = NULL;
+ virCapsHostCacheControlPtr control;
+
+ if (VIR_ALLOC(control) < 0)
+ goto cleanup;
+
+ if ((scope > VIR_CACHE_TYPE_BOTH)
+ && (virStringToUpper(&type_upper, virCacheTypeToString(scope)) < 0))
+ goto cleanup;
+
+ if (virFileReadValueUint(&control->max_allocation,
+ SYSFS_RESCTRL_PATH "/info/L%u%s/num_closids",
+ bank->level,
+ type_upper ? type_upper : "") < 0)
+ goto cleanup;
+
+ if (virFileReadValueString(&cbm_mask,
+ SYSFS_RESCTRL_PATH
+ "/info/L%u%s/cbm_mask",
+ bank->level,
+ type_upper ? type_upper: "") < 0)
+ goto cleanup;
+
+ virStringTrimOptionalNewline(cbm_mask);
+
+ /* cbm_mask: cache bit mask, it's in hex, eg: fffff */
+ control->min = bank->size / (strlen(cbm_mask) * 4);
+
+ control->scope = scope;
+
+ if (VIR_APPEND_ELEMENT(bank->controls,
+ bank->ncontrols,
+ control) < 0)
+ goto cleanup;
+
+ ret = 0;
+
+ cleanup:
+ VIR_FREE(path);
+ VIR_FREE(cbm_mask);
+ VIR_FREE(type_upper);
+ VIR_FREE(control);
+ return ret;
+}
+
int
virCapabilitiesInitCaches(virCapsPtr caps)
{
@@ -1534,6 +1649,7 @@ virCapabilitiesInitCaches(virCapsPtr caps)
ssize_t pos = -1;
DIR *dirp = NULL;
int ret = -1;
+ int typeret;
char *path = NULL;
char *type = NULL;
struct dirent *ent = NULL;
@@ -1609,6 +1725,26 @@ virCapabilitiesInitCaches(virCapsPtr caps)
SYSFS_SYSTEM_PATH, pos, ent->d_name) < 0)
goto cleanup;
+ typeret = virCapabilitiesGetCacheControlType(bank);
+
+ if ((bank->level >= cache_min_level) || (typeret >= 0)) {
+ if (typeret == 0) {
+ if (virCapabilitiesGetCacheControl(bank,
+ VIR_CACHE_TYPE_BOTH) < 0)
+ goto cleanup;
+ } else if (typeret == 1) {
+ if ((virCapabilitiesGetCacheControl(bank,
+ VIR_CACHE_TYPE_CODE) < 0) ||
+ (virCapabilitiesGetCacheControl(bank,
+ VIR_CACHE_TYPE_DATA) < 0))
+ goto cleanup;
+ }
+ } else {
+ virCapsHostCacheBankFree(bank);
+ bank = NULL;
+ continue;
+ }
+
kernel_type = virCacheKernelTypeFromString(type);
if (kernel_type < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
diff --git a/src/conf/capabilities.h b/src/conf/capabilities.h
index a8cccf7..598016d 100644
--- a/src/conf/capabilities.h
+++ b/src/conf/capabilities.h
@@ -146,6 +146,16 @@ typedef enum {
VIR_CACHE_TYPE_LAST
} virCacheType;
+VIR_ENUM_DECL(virResctrlCache);
+
+typedef struct _virCapsHostCacheControl virCapsHostCacheControl;
+typedef virCapsHostCacheControl *virCapsHostCacheControlPtr;
+struct _virCapsHostCacheControl {
+ unsigned long long min; /* minimum cache control size in B */
+ virCacheType scope; /* data, code or both */
+ unsigned int max_allocation; /* max number of supported allocations */
+};
+
VIR_ENUM_DECL(virCache);
typedef struct _virCapsHostCacheBank virCapsHostCacheBank;
@@ -156,6 +166,8 @@ struct _virCapsHostCacheBank {
unsigned long long size; /* B */
virCacheType type; /* Data, Instruction or Unified */
virBitmapPtr cpus; /* All CPUs that share this bank */
+ size_t ncontrols;
+ virCapsHostCacheControlPtr *controls;
};
typedef struct _virCapsHost virCapsHost;
diff --git a/tests/vircaps2xmldata/linux-resctrl-cdp/resctrl/cpus b/tests/vircaps2xmldata/linux-resctrl-cdp/resctrl/cpus
new file mode 100644
index 0000000..b3a79aa
--- /dev/null
+++ b/tests/vircaps2xmldata/linux-resctrl-cdp/resctrl/cpus
@@ -0,0 +1 @@
+ffffff,ffffffff,ffffffff
diff --git a/tests/vircaps2xmldata/linux-resctrl-cdp/resctrl/info/L3CODE/cbm_mask b/tests/vircaps2xmldata/linux-resctrl-cdp/resctrl/info/L3CODE/cbm_mask
new file mode 100755
index 0000000..78031da
--- /dev/null
+++ b/tests/vircaps2xmldata/linux-resctrl-cdp/resctrl/info/L3CODE/cbm_mask
@@ -0,0 +1 @@
+fffff
diff --git a/tests/vircaps2xmldata/linux-resctrl-cdp/resctrl/info/L3CODE/min_cbm_bits b/tests/vircaps2xmldata/linux-resctrl-cdp/resctrl/info/L3CODE/min_cbm_bits
new file mode 100755
index 0000000..d00491f
--- /dev/null
+++ b/tests/vircaps2xmldata/linux-resctrl-cdp/resctrl/info/L3CODE/min_cbm_bits
@@ -0,0 +1 @@
+1
diff --git a/tests/vircaps2xmldata/linux-resctrl-cdp/resctrl/info/L3CODE/num_closids b/tests/vircaps2xmldata/linux-resctrl-cdp/resctrl/info/L3CODE/num_closids
new file mode 100755
index 0000000..45a4fb7
--- /dev/null
+++ b/tests/vircaps2xmldata/linux-resctrl-cdp/resctrl/info/L3CODE/num_closids
@@ -0,0 +1 @@
+8
diff --git a/tests/vircaps2xmldata/linux-resctrl-cdp/resctrl/info/L3DATA/cbm_mask b/tests/vircaps2xmldata/linux-resctrl-cdp/resctrl/info/L3DATA/cbm_mask
new file mode 100755
index 0000000..78031da
--- /dev/null
+++ b/tests/vircaps2xmldata/linux-resctrl-cdp/resctrl/info/L3DATA/cbm_mask
@@ -0,0 +1 @@
+fffff
diff --git a/tests/vircaps2xmldata/linux-resctrl-cdp/resctrl/info/L3DATA/min_cbm_bits b/tests/vircaps2xmldata/linux-resctrl-cdp/resctrl/info/L3DATA/min_cbm_bits
new file mode 100755
index 0000000..d00491f
--- /dev/null
+++ b/tests/vircaps2xmldata/linux-resctrl-cdp/resctrl/info/L3DATA/min_cbm_bits
@@ -0,0 +1 @@
+1
diff --git a/tests/vircaps2xmldata/linux-resctrl-cdp/resctrl/info/L3DATA/num_closids b/tests/vircaps2xmldata/linux-resctrl-cdp/resctrl/info/L3DATA/num_closids
new file mode 100755
index 0000000..45a4fb7
--- /dev/null
+++ b/tests/vircaps2xmldata/linux-resctrl-cdp/resctrl/info/L3DATA/num_closids
@@ -0,0 +1 @@
+8
diff --git a/tests/vircaps2xmldata/linux-resctrl-cdp/resctrl/manualres/cpus b/tests/vircaps2xmldata/linux-resctrl-cdp/resctrl/manualres/cpus
new file mode 100644
index 0000000..ede4cc2
--- /dev/null
+++ b/tests/vircaps2xmldata/linux-resctrl-cdp/resctrl/manualres/cpus
@@ -0,0 +1 @@
+000000,00000000,00000000
diff --git a/tests/vircaps2xmldata/linux-resctrl-cdp/resctrl/manualres/schemata b/tests/vircaps2xmldata/linux-resctrl-cdp/resctrl/manualres/schemata
new file mode 100644
index 0000000..a0ef381
--- /dev/null
+++ b/tests/vircaps2xmldata/linux-resctrl-cdp/resctrl/manualres/schemata
@@ -0,0 +1,2 @@
+L3DATA:0=c0000;1=c0000
+L3CODE:0=30000;1=30000
diff --git a/tests/vircaps2xmldata/linux-resctrl-cdp/resctrl/manualres/tasks b/tests/vircaps2xmldata/linux-resctrl-cdp/resctrl/manualres/tasks
new file mode 100644
index 0000000..e69de29
diff --git a/tests/vircaps2xmldata/linux-resctrl-cdp/resctrl/schemata b/tests/vircaps2xmldata/linux-resctrl-cdp/resctrl/schemata
new file mode 100644
index 0000000..89dc76b
--- /dev/null
+++ b/tests/vircaps2xmldata/linux-resctrl-cdp/resctrl/schemata
@@ -0,0 +1,2 @@
+L3DATA:0=fffff;1=fffff
+L3CODE:0=fffff;1=fffff
diff --git a/tests/vircaps2xmldata/linux-resctrl-cdp/resctrl/tasks b/tests/vircaps2xmldata/linux-resctrl-cdp/resctrl/tasks
new file mode 100644
index 0000000..e69de29
diff --git a/tests/vircaps2xmldata/linux-resctrl-cdp/system b/tests/vircaps2xmldata/linux-resctrl-cdp/system
new file mode 120000
index 0000000..2f3a1d9
--- /dev/null
+++ b/tests/vircaps2xmldata/linux-resctrl-cdp/system
@@ -0,0 +1 @@
+../linux-resctrl/system/
\ No newline at end of file
diff --git a/tests/vircaps2xmldata/vircaps-x86_64-resctrl-cdp.xml b/tests/vircaps2xmldata/vircaps-x86_64-resctrl-cdp.xml
new file mode 100644
index 0000000..c9f460d
--- /dev/null
+++ b/tests/vircaps2xmldata/vircaps-x86_64-resctrl-cdp.xml
@@ -0,0 +1,55 @@
+<capabilities>
+
+ <host>
+ <cpu>
+ <arch>x86_64</arch>
+ </cpu>
+ <power_management/>
+ <migration_features>
+ <live/>
+ </migration_features>
+ <topology>
+ <cells num='2'>
+ <cell id='0'>
+ <memory unit='KiB'>1048576</memory>
+ <pages unit='KiB' size='4'>2048</pages>
+ <pages unit='KiB' size='2048'>4096</pages>
+ <pages unit='KiB' size='1048576'>6144</pages>
+ <cpus num='6'>
+ <cpu id='0' socket_id='0' core_id='0' siblings='0'/>
+ <cpu id='1' socket_id='0' core_id='1' siblings='1'/>
+ <cpu id='2' socket_id='0' core_id='2' siblings='2'/>
+ <cpu id='3' socket_id='0' core_id='3' siblings='3'/>
+ <cpu id='4' socket_id='0' core_id='4' siblings='4'/>
+ <cpu id='5' socket_id='0' core_id='5' siblings='5'/>
+ </cpus>
+ </cell>
+ <cell id='1'>
+ <memory unit='KiB'>2097152</memory>
+ <pages unit='KiB' size='4'>4096</pages>
+ <pages unit='KiB' size='2048'>6144</pages>
+ <pages unit='KiB' size='1048576'>8192</pages>
+ <cpus num='6'>
+ <cpu id='6' socket_id='1' core_id='0' siblings='6'/>
+ <cpu id='7' socket_id='1' core_id='1' siblings='7'/>
+ <cpu id='8' socket_id='1' core_id='2' siblings='8'/>
+ <cpu id='9' socket_id='1' core_id='3' siblings='9'/>
+ <cpu id='10' socket_id='1' core_id='4' siblings='10'/>
+ <cpu id='11' socket_id='1' core_id='5' siblings='11'/>
+ </cpus>
+ </cell>
+ </cells>
+ </topology>
+ <cache>
+ <bank id='0' level='3' type='both' size='15360' unit='KiB' cpus='0-5'>
+ <control min='768' unit='KiB' scope='code' max_allocation='8'/>
+ <control min='768' unit='KiB' scope='data' max_allocation='8'/>
+ </bank>
+ <bank id='1' level='3' type='both' size='15360' unit='KiB' cpus='6-11'>
+ <control min='768' unit='KiB' scope='code' max_allocation='8'/>
+ <control min='768' unit='KiB' scope='data' max_allocation='8'/>
+ </bank>
+ </cache>
+ </host>
+
+</capabilities>
diff --git a/tests/vircaps2xmldata/vircaps-x86_64-resctrl.xml b/tests/vircaps2xmldata/vircaps-x86_64-resctrl.xml
index 6677791..04a5eb8 100644
--- a/tests/vircaps2xmldata/vircaps-x86_64-resctrl.xml
+++ b/tests/vircaps2xmldata/vircaps-x86_64-resctrl.xml
@@ -41,8 +41,12 @@
</cells>
</topology>
<cache>
- <bank id='0' level='3' type='both' size='15360' unit='KiB' cpus='0-5'/>
- <bank id='1' level='3' type='both' size='15360' unit='KiB' cpus='6-11'/>
+ <bank id='0' level='3' type='both' size='15360' unit='KiB' cpus='0-5'>
+ <control min='768' unit='KiB' scope='both' max_allocation='4'/>
+ </bank>
+ <bank id='1' level='3' type='both' size='15360' unit='KiB' cpus='6-11'>
+ <control min='768' unit='KiB' scope='both' max_allocation='4'/>
+ </bank>
</cache>
</host>
diff --git a/tests/vircaps2xmltest.c b/tests/vircaps2xmltest.c
index 137598e..c5887af 100644
--- a/tests/vircaps2xmltest.c
+++ b/tests/vircaps2xmltest.c
@@ -47,6 +47,7 @@ test_virCapabilities(const void *opaque)
char *capsXML = NULL;
char *path = NULL;
char *dir = NULL;
+ char *resctrl = NULL;
int ret = -1;
/*
@@ -58,7 +59,12 @@ test_virCapabilities(const void *opaque)
data->resctrl ? "/system" : "") < 0)
goto cleanup;
- virFileWrapperAddPrefix("/sys/devices/system", dir);
+ if (virAsprintf(&resctrl, "%s/vircaps2xmldata/linux-%s/resctrl",
+ abs_srcdir, data->filename) < 0)
+ goto cleanup;
+
+virFileWrapperAddPrefix("/sys/devices/system", dir);
+virFileWrapperAddPrefix("/sys/fs/resctrl", resctrl);
caps = virCapabilitiesNew(data->arch, data->offlineMigrate, data->liveMigrate);
if (!caps)
@@ -84,6 +90,7 @@ test_virCapabilities(const void *opaque)
cleanup:
VIR_FREE(dir);
+ VIR_FREE(resctrl);
VIR_FREE(path);
VIR_FREE(capsXML);
virObjectUnref(caps);
@@ -112,6 +119,7 @@ mymain(void)
DO_TEST("caches", VIR_ARCH_X86_64);
DO_TEST_FULL("resctrl", VIR_ARCH_X86_64, true, true, true);
+ DO_TEST_FULL("resctrl-cdp", VIR_ARCH_X86_64, true, true, true);
return ret;
}
--
1.9.1
7 years, 6 months
[libvirt] [PATCH 0/2] Fix issue with attempting to use polkit
by John Ferlan
The "issue" is when using a remote URI and authn when attempting to connect
to the local system when a local URI and usage of pkttyagent was "expected"
for local authn.
The current bug is:
https://bugzilla.redhat.com/show_bug.cgi?id=1374126
which was "forked off" from:
https://bugzilla.redhat.com/show_bug.cgi?id=986365
which added the support for pkttyagent processing for "local" authn when
the GUI option wasn't available (e.g. when ssh@localhost, run virsh) in
order to perform the authn of the user.
This is one of those "either" patch 1 or patch 2 will fix the problem,
but I really couldn't decide which I liked better. I'm leaning towards
the second one only because of the one authn failure; however, I'm not
sure I like the escape path comparison to ":///".
With only the first patch one would get two challenge/responses before
failure, e.g.:
$ virsh -c qemu+ssh://someuser@localhost/system list --all
someuser@localhost's password:
someuser@localhost's password:
error: failed to connect to the hypervisor
error: authentication unavailable: no polkit agent available to authenticate action 'org.libvirt.unix.manage'
$
With the second patch one would get one challenge/reponse before failure e.g.:
$ virsh -c qemu+ssh://someuser@localhost/system list --all
someuser@localhost's password:
error: failed to connect to the hypervisor
error: authentication unavailable: no polkit agent available to authenticate action 'org.libvirt.unix.manage'
$
Going with #2 restores essentially older (e.g. 1.3.4) processing when the
pkttyagent processing loop didn't exist.
The challenge/response in either case comes from ssh and is successful;
however, code in remoteDispatchAuthList doesn't let a non root user to
take this URI option for a local authn/authz because the callerUid is
not 0 (root). Although, I suppose it would be possible to check whether
the @callerUid was authorized (e.g. part of some group), but that I think
"outside" the scope of what the bz is reporting, so I didn't take that route.
The reality is the bug is mostly a problem for non UI type processing
where providing that ctrl-c to quit isn't as likely/possible.
John Ferlan (2):
virsh: Track when create pkttyagent
virsh: Don't attempt polkit processing for non local authn/authz
tools/virsh.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
--
2.9.3
7 years, 6 months
[libvirt] [PATCH] usb: keep leading zeros of vendor/product id in USB device
by Chen Hanxiao
From: Chen Hanxiao <chenhanxiao(a)gmail.com>
Some vendor id or product id may have leading zeros.
We should show them.
Signed-off-by: Chen Hanxiao <chenhanxiao(a)gmail.com>
---
src/util/virusb.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/util/virusb.c b/src/util/virusb.c
index 8cd2f57..6359235 100644
--- a/src/util/virusb.c
+++ b/src/util/virusb.c
@@ -221,7 +221,7 @@ virUSBDeviceFindByVendor(unsigned int vendor,
if (list->count == 0) {
virObjectUnref(list);
if (!mandatory) {
- VIR_DEBUG("Did not find USB device %x:%x",
+ VIR_DEBUG("Did not find USB device %04x:%04x",
vendor, product);
if (devices)
*devices = NULL;
@@ -229,7 +229,7 @@ virUSBDeviceFindByVendor(unsigned int vendor,
}
virReportError(VIR_ERR_INTERNAL_ERROR,
- _("Did not find USB device %x:%x"), vendor, product);
+ _("Did not find USB device %04x:%04x"), vendor, product);
return -1;
}
@@ -300,7 +300,7 @@ virUSBDeviceFind(unsigned int vendor,
if (list->count == 0) {
virObjectUnref(list);
if (!mandatory) {
- VIR_DEBUG("Did not find USB device %x:%x bus:%u device:%u",
+ VIR_DEBUG("Did not find USB device %04x:%04x bus:%u device:%u",
vendor, product, bus, devno);
if (usb)
*usb = NULL;
@@ -308,7 +308,7 @@ virUSBDeviceFind(unsigned int vendor,
}
virReportError(VIR_ERR_INTERNAL_ERROR,
- _("Did not find USB device %x:%x bus:%u device:%u"),
+ _("Did not find USB device %04x:%04x bus:%u device:%u"),
vendor, product, bus, devno);
return -1;
}
--
2.7.4
7 years, 6 months
[libvirt] [PATCH 00/13] Make the virNodeDeviceObjPtr private
by John Ferlan
All part of the effort I have to have a common object model. This series
is node device test, driver, and virnodedevobj related.
There's also a couple of bug fixes at the beginning of the series from
things I have found during this effort.
There's still a few more patches in local branches to make the
virNodeDeviceObjListPtr private as well, but those have some merge
needs with other patches currently on list elsewhere, so I'll hold
onto them for now.
John Ferlan (13):
test: Adjust cleanup/error paths for nodedev test APIs
nodedev: Fix locking in virNodeDeviceObjRemove
nodedev: Need to check for vport capable scsi_host for vHBA searches
nodedev: Move node_device_linux_sysfs from node_driver to conf
nodedev: Use common naming for virnodedeviceobj
nodedev: Cleanup driver code and prototypes
nodedev: Alter param to nodeDeviceUpdateDriverName
nodedev: Alter param to nodeDeviceUpdateCaps
nodedev: Create helper for finding by name in driver
nodedev: Use consistent names for driver variables
nodedev: Introduce virNodeDeviceObjGetDef
nodedev: Remove privateData from virNodeDeviceObj
nodedev: Introduce virNodeDeviceObjNew
src/Makefile.am | 8 +-
src/conf/node_device_conf.h | 2 -
.../node_device_linux_sysfs.c | 24 +-
.../node_device_linux_sysfs.h | 9 +-
src/conf/virnodedeviceobj.c | 170 ++++++-----
src/conf/virnodedeviceobj.h | 2 +
src/libvirt_private.syms | 6 +
src/node_device/node_device_driver.c | 235 +++++++--------
src/node_device/node_device_driver.h | 93 ++++--
src/node_device/node_device_hal.c | 60 ++--
src/node_device/node_device_udev.c | 323 ++++++++++++---------
src/test/test_driver.c | 113 ++++---
12 files changed, 576 insertions(+), 469 deletions(-)
rename src/{node_device => conf}/node_device_linux_sysfs.c (89%)
rename src/{node_device => conf}/node_device_linux_sysfs.h (82%)
--
2.9.3
7 years, 6 months
[libvirt] [PATCH 0/2] Add eim attribute to iommu device
by Ján Tomko
Extended interrupt mode allows >255 vCPUs with q35-based machine types.
https://bugzilla.redhat.com/show_bug.cgi?id=1451282
Ján Tomko (2):
conf: add eim attribute to <iommu><driver>
qemu: format eim on intel-iommu command line
docs/formatdomain.html.in | 10 +++++++
docs/schemas/domaincommon.rng | 5 ++++
src/conf/domain_conf.c | 20 ++++++++++++++
src/conf/domain_conf.h | 1 +
src/qemu/qemu_capabilities.c | 2 ++
src/qemu/qemu_capabilities.h | 1 +
src/qemu/qemu_command.c | 11 ++++++++
src/qemu/qemu_domain.c | 20 ++++++++++++++
tests/qemucapabilitiesdata/caps_2.8.0.x86_64.xml | 1 +
tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml | 1 +
.../qemuxml2argv-intel-iommu-eim.args | 19 +++++++++++++
.../qemuxml2argv-intel-iommu-eim.xml | 31 ++++++++++++++++++++++
tests/qemuxml2argvtest.c | 7 +++++
.../qemuxml2xmlout-intel-iommu-eim.xml | 1 +
tests/qemuxml2xmltest.c | 1 +
15 files changed, 131 insertions(+)
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-intel-iommu-eim.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-intel-iommu-eim.xml
create mode 120000 tests/qemuxml2xmloutdata/qemuxml2xmlout-intel-iommu-eim.xml
--
2.10.2
7 years, 6 months
[libvirt] [PATCH python] Fix error check for virDomainGetTime method
by Daniel P. Berrange
The virDomainGetTime returns either a dict or None, but the python
glue layer for checking for '-1'. Thus it failed to raise an
exception on error.
Signed-off-by: Daniel P. Berrange <berrange(a)redhat.com>
---
libvirt-override-virDomain.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libvirt-override-virDomain.py b/libvirt-override-virDomain.py
index fa5f75f..7c417b8 100644
--- a/libvirt-override-virDomain.py
+++ b/libvirt-override-virDomain.py
@@ -63,7 +63,7 @@
def getTime(self, flags=0):
"""Extract information about guest time """
ret = libvirtmod.virDomainGetTime(self._o, flags)
- if ret == -1: raise libvirtError ('virDomainGetTime() failed', dom=self)
+ if ret == None: raise libvirtError ('virDomainGetTime() failed', dom=self)
return ret
def setTime(self, time=None, flags=0):
--
2.9.3
7 years, 6 months
[libvirt] [PATCH] conf: Resolve corner case on fc_host deletion
by John Ferlan
https://bugzilla.redhat.com/show_bug.cgi?id=1420740
Testing found an inventive way to cause an error at shutdown by providing the
parent name for the fc host creation using the "same name" as the HBA. Since
the code thus assumed the parent host name provided was the parent HBA and
just extracted out the host number and sent that along to the vport_destroy
this avoided checks made for equality.
So just add the equality check to that path to resolve.
Signed-off-by: John Ferlan <jferlan(a)redhat.com>
---
src/conf/node_device_conf.c | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c
index 85cfd83..3f995da 100644
--- a/src/conf/node_device_conf.c
+++ b/src/conf/node_device_conf.c
@@ -2127,17 +2127,25 @@ virNodeDeviceDeleteVport(virConnectPtr conn,
goto cleanup;
}
+ if (virAsprintf(&scsi_host_name, "scsi_%s", name) < 0)
+ goto cleanup;
+
/* If at startup time we provided a parent, then use that to
* get the parent_host value; otherwise, we have to determine
* the parent scsi_host which we did not save at startup time
*/
if (fchost->parent) {
+ /* Someone provided a parent string at startup time that
+ * was the same as the scsi_host - meaning we have a pool
+ * backed to an HBA, so there won't be a vHBA to delete */
+ if (STREQ(scsi_host_name, fchost->parent)) {
+ ret = 0;
+ goto cleanup;
+ }
+
if (virSCSIHostGetNumber(fchost->parent, &parent_host) < 0)
goto cleanup;
} else {
- if (virAsprintf(&scsi_host_name, "scsi_%s", name) < 0)
- goto cleanup;
-
if (!(vhba_parent = virNodeDeviceGetParentName(conn, scsi_host_name)))
goto cleanup;
--
2.9.3
7 years, 6 months
[libvirt] [PATCH] conf: fix build issue caused by shadowing global declaration
by Pavel Hrdina
Signed-off-by: Pavel Hrdina <phrdina(a)redhat.com>
---
Pushed under build-breaker rule.
src/conf/domain_conf.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 32234e8a54..d3c6e9c0ab 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -3525,12 +3525,12 @@ void virDomainDeviceInfoClear(virDomainDeviceInfoPtr info)
static bool
virDomainSkipBackcompatConsole(virDomainDefPtr def,
- size_t index,
+ size_t idx,
bool all)
{
- virDomainChrDefPtr console = def->consoles[index];
+ virDomainChrDefPtr console = def->consoles[idx];
- if (!all && index == 0 &&
+ if (!all && idx == 0 &&
(console->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL ||
console->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_NONE) &&
def->os.type == VIR_DOMAIN_OSTYPE_HVM) {
--
2.13.0
7 years, 6 months