[libvirt] [PATCH] scsi: Force error for SCSI pools on virStorageBackendSCSIFindLUs failure
by John Ferlan
Related to :
https://bugzilla.redhat.com/show_bug.cgi?id=1171933
Rather than ignore the return status from virStorageBackendSCSIFindLUs,
cause a failure to start the pool if a -1 is returned. Issue was noted
during testing of the bz for iscsi that 'scsi' and 'fc' pools don't fail.
Signed-off-by: John Ferlan <jferlan(a)redhat.com>
---
src/storage/storage_backend_scsi.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/storage/storage_backend_scsi.c b/src/storage/storage_backend_scsi.c
index b426145..a593a2b 100644
--- a/src/storage/storage_backend_scsi.c
+++ b/src/storage/storage_backend_scsi.c
@@ -935,7 +935,8 @@ virStorageBackendSCSIRefreshPool(virConnectPtr conn ATTRIBUTE_UNUSED,
if (virStorageBackendSCSITriggerRescan(host) < 0)
goto out;
- ignore_value(virStorageBackendSCSIFindLUs(pool, host));
+ if (virStorageBackendSCSIFindLUs(pool, host) < 0)
+ goto out;
ret = 0;
out:
--
2.1.0
9 years, 5 months
[libvirt] [PATCH] vircapstest: Properly report error for failed tests
by Michal Privoznik
There are two macros used in the test: CAPSCOMP and CAPS_EXPECT_ERR.
Both run a test case and if a failure occurred, they set the @ret
variable to a value of -1 to indicate an error. Well, that's what they
should do. Due to a typo, they set the variable to a positive one
effectively masking any failed test.
Then, we have couple of tests failing. Fix them too.
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
tests/vircapstest.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/tests/vircapstest.c b/tests/vircapstest.c
index 0c79af8..3b41654 100644
--- a/tests/vircapstest.c
+++ b/tests/vircapstest.c
@@ -204,11 +204,11 @@ doCapsCompare(virCapsPtr caps,
#define CAPSCOMP(o, a, d, e, m, fo, fa, fd, fe, fm) \
if (!doCapsCompare(caps, o, a, d, e, m, fo, fa, fd, fe, fm)) \
- ret = 1;
+ ret = -1;
#define CAPS_EXPECT_ERR(o, a, d, e, m) \
if (!doCapsExpectFailure(caps, o, a, d, e, m)) \
- ret = 1;
+ ret = -1;
#ifdef WITH_QEMU
static int
@@ -224,11 +224,11 @@ test_virCapsDomainDataLookupQEMU(const void *data ATTRIBUTE_UNUSED)
/* Checking each parameter individually */
CAPSCOMP(-1, VIR_ARCH_NONE, -1, NULL, NULL,
- VIR_DOMAIN_OSTYPE_HVM, VIR_ARCH_I686,
- VIR_DOMAIN_VIRT_QEMU, "/usr/bin/qemu", "pc");
+ VIR_DOMAIN_OSTYPE_HVM, VIR_ARCH_X86_64,
+ VIR_DOMAIN_VIRT_QEMU, "/usr/bin/qemu-system-x86_64", "pc-0.11");
CAPSCOMP(VIR_DOMAIN_OSTYPE_HVM, VIR_ARCH_NONE, -1, NULL, NULL,
- VIR_DOMAIN_OSTYPE_HVM, VIR_ARCH_I686,
- VIR_DOMAIN_VIRT_QEMU, "/usr/bin/qemu", "pc");
+ VIR_DOMAIN_OSTYPE_HVM, VIR_ARCH_X86_64,
+ VIR_DOMAIN_VIRT_QEMU, "/usr/bin/qemu-system-x86_64", "pc-0.11");
CAPSCOMP(-1, VIR_ARCH_AARCH64, -1, NULL, NULL,
VIR_DOMAIN_OSTYPE_HVM, VIR_ARCH_AARCH64,
VIR_DOMAIN_VIRT_QEMU, "/usr/bin/qemu-system-aarch64", "virt");
@@ -306,7 +306,7 @@ test_virCapsDomainDataLookupLXC(const void *data ATTRIBUTE_UNUSED)
}
CAPSCOMP(-1, VIR_ARCH_NONE, -1, NULL, NULL,
- VIR_DOMAIN_OSTYPE_EXE, VIR_ARCH_I686,
+ VIR_DOMAIN_OSTYPE_EXE, VIR_ARCH_X86_64,
VIR_DOMAIN_VIRT_LXC, "/usr/libexec/libvirt_lxc", NULL);
CAPSCOMP(-1, VIR_ARCH_X86_64, -1, NULL, NULL,
VIR_DOMAIN_OSTYPE_EXE, VIR_ARCH_X86_64,
--
2.3.6
9 years, 5 months
[libvirt] [PATCH] virt-aa-helper: fix rules for paths with trailing slash
by Cédric Bosdonnat
Rules generated for a path like '/' were having '//' which isn't
correct for apparmor. Make virt-aa-helper smarter to avoid these.
---
src/security/virt-aa-helper.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/src/security/virt-aa-helper.c b/src/security/virt-aa-helper.c
index 35423b5..9f1c570 100644
--- a/src/security/virt-aa-helper.c
+++ b/src/security/virt-aa-helper.c
@@ -773,6 +773,7 @@ vah_add_path(virBufferPtr buf, const char *path, const char *perms, bool recursi
char *tmp = NULL;
int rc = -1;
bool readonly = true;
+ bool trailingSlash;
if (path == NULL)
return rc;
@@ -809,14 +810,18 @@ vah_add_path(virBufferPtr buf, const char *path, const char *perms, bool recursi
goto cleanup;
}
- virBufferAsprintf(buf, " \"%s%s\" %s,\n", tmp, recursive ? "/**" : "", perms);
+ trailingSlash = (tmp[strlen(tmp) - 1] == '/');
+
+ virBufferAsprintf(buf, " \"%s%s%s\" %s,\n", tmp, trailingSlash ? "" : "/",
+ recursive ? "**" : "", perms);
if (readonly) {
virBufferAddLit(buf, " # don't audit writes to readonly files\n");
- virBufferAsprintf(buf, " deny \"%s%s\" w,\n", tmp, recursive ? "/**" : "");
+ virBufferAsprintf(buf, " deny \"%s%s%s\" w,\n", tmp,
+ trailingSlash ? "" : "/", recursive ? "**" : "");
}
if (recursive) {
/* allow reading (but not creating) the dir */
- virBufferAsprintf(buf, " \"%s/\" r,\n", tmp);
+ virBufferAsprintf(buf, " \"%s%s\" r,\n", tmp, trailingSlash ? "" : "/");
}
cleanup:
--
2.1.4
9 years, 5 months
[libvirt] [PATCH v2] qemu: Use heads parameter for QXL driver
by Frediano Ziglio
Allows to specify maximum number of head to QXL driver.
Signed-off-by: Frediano Ziglio <fziglio(a)redhat.com>
The patch to support the "max_outputs" in Qemu is still not merged but
I got agreement on the name of the argument.
Actually can be a compatiblity problem as heads in the XML configuration
was set by default to '1'.
---
src/qemu/qemu_capabilities.c | 3 +++
src/qemu/qemu_capabilities.h | 1 +
src/qemu/qemu_command.c | 5 +++++
tests/qemucapabilitiesdata/caps_1.2.2-1.caps | 1 +
tests/qemucapabilitiesdata/caps_1.2.2-1.replies | 8 ++++++++
tests/qemucapabilitiesdata/caps_1.3.1-1.caps | 1 +
tests/qemucapabilitiesdata/caps_1.3.1-1.replies | 8 ++++++++
tests/qemucapabilitiesdata/caps_1.4.2-1.caps | 1 +
tests/qemucapabilitiesdata/caps_1.4.2-1.replies | 8 ++++++++
tests/qemucapabilitiesdata/caps_1.5.3-1.caps | 1 +
tests/qemucapabilitiesdata/caps_1.5.3-1.replies | 8 ++++++++
tests/qemucapabilitiesdata/caps_1.6.0-1.caps | 1 +
tests/qemucapabilitiesdata/caps_1.6.0-1.replies | 8 ++++++++
tests/qemucapabilitiesdata/caps_1.6.50-1.caps | 1 +
tests/qemucapabilitiesdata/caps_1.6.50-1.replies | 8 ++++++++
tests/qemucapabilitiesdata/caps_2.1.1-1.caps | 1 +
tests/qemucapabilitiesdata/caps_2.1.1-1.replies | 8 ++++++++
17 files changed, 72 insertions(+)
Changes from v1:
- fix formatting for capability strings;
- remove global parameters, impossible to reach;
- removed RFC.
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index ca7a7c2..a676c41 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -285,6 +285,8 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST,
"dea-key-wrap",
"pci-serial",
"aarch64-off",
+
+ "qxl-vga.max_outputs", /* 190 */
);
@@ -1643,6 +1645,7 @@ static struct virQEMUCapsStringFlags virQEMUCapsObjectPropsQxl[] = {
static struct virQEMUCapsStringFlags virQEMUCapsObjectPropsQxlVga[] = {
{ "vgamem_mb", QEMU_CAPS_QXL_VGA_VGAMEM },
+ { "max_outputs", QEMU_CAPS_QXL_VGA_MAX_OUTPUTS },
};
struct virQEMUCapsObjectTypeProps {
diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
index b5a7770..a2ea84b 100644
--- a/src/qemu/qemu_capabilities.h
+++ b/src/qemu/qemu_capabilities.h
@@ -229,6 +229,7 @@ typedef enum {
QEMU_CAPS_DEA_KEY_WRAP = 187, /* -machine dea_key_wrap */
QEMU_CAPS_DEVICE_PCI_SERIAL = 188, /* -device pci-serial */
QEMU_CAPS_CPU_AARCH64_OFF = 189, /* -cpu ...,aarch64=off */
+ QEMU_CAPS_QXL_VGA_MAX_OUTPUTS = 190, /* qxl-vga.max_outputs */
QEMU_CAPS_LAST, /* this must always be the last item */
} virQEMUCapsFlags;
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 0a6d92f..a9d9169 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -5610,6 +5610,11 @@ qemuBuildDeviceVideoStr(virDomainDefPtr def,
/* QEMU accepts mebibytes for vgamem_mb. */
virBufferAsprintf(&buf, ",vgamem_mb=%u", video->vgamem / 1024);
}
+
+ if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_QXL_VGA_MAX_OUTPUTS) &&
+ video->heads > 0) {
+ virBufferAsprintf(&buf, ",max_outputs=%u", video->heads);
+ }
} else if (video->vram &&
((video->type == VIR_DOMAIN_VIDEO_TYPE_VGA &&
virQEMUCapsGet(qemuCaps, QEMU_CAPS_VGA_VGAMEM)) ||
diff --git a/tests/qemucapabilitiesdata/caps_1.2.2-1.caps b/tests/qemucapabilitiesdata/caps_1.2.2-1.caps
index 30239df..7791e42 100644
--- a/tests/qemucapabilitiesdata/caps_1.2.2-1.caps
+++ b/tests/qemucapabilitiesdata/caps_1.2.2-1.caps
@@ -120,4 +120,5 @@
<flag name='vmware-svga.vgamem_mb'/>
<flag name='qxl.vgamem_mb'/>
<flag name='qxl-vga.vgamem_mb'/>
+ <flag name='qxl-vga.max_outputs'/>
</qemuCaps>
diff --git a/tests/qemucapabilitiesdata/caps_1.2.2-1.replies b/tests/qemucapabilitiesdata/caps_1.2.2-1.replies
index f501218..aa1d3f9 100644
--- a/tests/qemucapabilitiesdata/caps_1.2.2-1.replies
+++ b/tests/qemucapabilitiesdata/caps_1.2.2-1.replies
@@ -1488,6 +1488,10 @@
"type": "pci-devfn"
},
{
+ "name": "max_outputs",
+ "type": "uint16"
+ },
+ {
"name": "vgamem_mb",
"type": "uint32"
},
@@ -1554,6 +1558,10 @@
"type": "pci-devfn"
},
{
+ "name": "max_outputs",
+ "type": "uint16"
+ },
+ {
"name": "vgamem_mb",
"type": "uint32"
},
diff --git a/tests/qemucapabilitiesdata/caps_1.3.1-1.caps b/tests/qemucapabilitiesdata/caps_1.3.1-1.caps
index ea3d850..bf4c731 100644
--- a/tests/qemucapabilitiesdata/caps_1.3.1-1.caps
+++ b/tests/qemucapabilitiesdata/caps_1.3.1-1.caps
@@ -135,4 +135,5 @@
<flag name='qxl.vgamem_mb'/>
<flag name='qxl-vga.vgamem_mb'/>
<flag name='pci-serial'/>
+ <flag name='qxl-vga.max_outputs'/>
</qemuCaps>
diff --git a/tests/qemucapabilitiesdata/caps_1.3.1-1.replies b/tests/qemucapabilitiesdata/caps_1.3.1-1.replies
index e1f9704..6e210fe 100644
--- a/tests/qemucapabilitiesdata/caps_1.3.1-1.replies
+++ b/tests/qemucapabilitiesdata/caps_1.3.1-1.replies
@@ -1659,6 +1659,10 @@
"type": "pci-devfn"
},
{
+ "name": "max_outputs",
+ "type": "uint16"
+ },
+ {
"name": "surfaces",
"type": "int32"
},
@@ -1729,6 +1733,10 @@
"type": "pci-devfn"
},
{
+ "name": "max_outputs",
+ "type": "uint16"
+ },
+ {
"name": "surfaces",
"type": "int32"
},
diff --git a/tests/qemucapabilitiesdata/caps_1.4.2-1.caps b/tests/qemucapabilitiesdata/caps_1.4.2-1.caps
index 2c19ddc..a371b57 100644
--- a/tests/qemucapabilitiesdata/caps_1.4.2-1.caps
+++ b/tests/qemucapabilitiesdata/caps_1.4.2-1.caps
@@ -136,4 +136,5 @@
<flag name='qxl.vgamem_mb'/>
<flag name='qxl-vga.vgamem_mb'/>
<flag name='pci-serial'/>
+ <flag name='qxl-vga.max_outputs'/>
</qemuCaps>
diff --git a/tests/qemucapabilitiesdata/caps_1.4.2-1.replies b/tests/qemucapabilitiesdata/caps_1.4.2-1.replies
index 3d797b2..2b97937 100644
--- a/tests/qemucapabilitiesdata/caps_1.4.2-1.replies
+++ b/tests/qemucapabilitiesdata/caps_1.4.2-1.replies
@@ -1706,6 +1706,10 @@
"type": "pci-devfn"
},
{
+ "name": "max_outputs",
+ "type": "uint16"
+ },
+ {
"name": "surfaces",
"type": "int32"
},
@@ -1776,6 +1780,10 @@
"type": "pci-devfn"
},
{
+ "name": "max_outputs",
+ "type": "uint16"
+ },
+ {
"name": "surfaces",
"type": "int32"
},
diff --git a/tests/qemucapabilitiesdata/caps_1.5.3-1.caps b/tests/qemucapabilitiesdata/caps_1.5.3-1.caps
index aadccd5..bb3d7aa 100644
--- a/tests/qemucapabilitiesdata/caps_1.5.3-1.caps
+++ b/tests/qemucapabilitiesdata/caps_1.5.3-1.caps
@@ -145,4 +145,5 @@
<flag name='qxl.vgamem_mb'/>
<flag name='qxl-vga.vgamem_mb'/>
<flag name='pci-serial'/>
+ <flag name='qxl-vga.max_outputs'/>
</qemuCaps>
diff --git a/tests/qemucapabilitiesdata/caps_1.5.3-1.replies b/tests/qemucapabilitiesdata/caps_1.5.3-1.replies
index 45571a3..1a67ab9 100644
--- a/tests/qemucapabilitiesdata/caps_1.5.3-1.replies
+++ b/tests/qemucapabilitiesdata/caps_1.5.3-1.replies
@@ -1780,6 +1780,10 @@
"type": "pci-devfn"
},
{
+ "name": "max_outputs",
+ "type": "uint16"
+ },
+ {
"name": "surfaces",
"type": "int32"
},
@@ -1850,6 +1854,10 @@
"type": "pci-devfn"
},
{
+ "name": "max_outputs",
+ "type": "uint16"
+ },
+ {
"name": "surfaces",
"type": "int32"
},
diff --git a/tests/qemucapabilitiesdata/caps_1.6.0-1.caps b/tests/qemucapabilitiesdata/caps_1.6.0-1.caps
index 3e81cbf..9d98f13 100644
--- a/tests/qemucapabilitiesdata/caps_1.6.0-1.caps
+++ b/tests/qemucapabilitiesdata/caps_1.6.0-1.caps
@@ -151,4 +151,5 @@
<flag name='qxl.vgamem_mb'/>
<flag name='qxl-vga.vgamem_mb'/>
<flag name='pci-serial'/>
+ <flag name='qxl-vga.max_outputs'/>
</qemuCaps>
diff --git a/tests/qemucapabilitiesdata/caps_1.6.0-1.replies b/tests/qemucapabilitiesdata/caps_1.6.0-1.replies
index ae4b3f4..3b187c5 100644
--- a/tests/qemucapabilitiesdata/caps_1.6.0-1.replies
+++ b/tests/qemucapabilitiesdata/caps_1.6.0-1.replies
@@ -1842,6 +1842,10 @@
"type": "pci-devfn"
},
{
+ "name": "max_outputs",
+ "type": "uint16"
+ },
+ {
"name": "surfaces",
"type": "int32"
},
@@ -1912,6 +1916,10 @@
"type": "pci-devfn"
},
{
+ "name": "max_outputs",
+ "type": "uint16"
+ },
+ {
"name": "surfaces",
"type": "int32"
},
diff --git a/tests/qemucapabilitiesdata/caps_1.6.50-1.caps b/tests/qemucapabilitiesdata/caps_1.6.50-1.caps
index 84c357f..ac1a3bd 100644
--- a/tests/qemucapabilitiesdata/caps_1.6.50-1.caps
+++ b/tests/qemucapabilitiesdata/caps_1.6.50-1.caps
@@ -151,4 +151,5 @@
<flag name='qxl.vgamem_mb'/>
<flag name='qxl-vga.vgamem_mb'/>
<flag name='pci-serial'/>
+ <flag name='qxl-vga.max_outputs'/>
</qemuCaps>
diff --git a/tests/qemucapabilitiesdata/caps_1.6.50-1.replies b/tests/qemucapabilitiesdata/caps_1.6.50-1.replies
index 90d31f0..52ddebb 100644
--- a/tests/qemucapabilitiesdata/caps_1.6.50-1.replies
+++ b/tests/qemucapabilitiesdata/caps_1.6.50-1.replies
@@ -1806,6 +1806,10 @@
"type": "pci-devfn"
},
{
+ "name": "max_outputs",
+ "type": "uint16"
+ },
+ {
"name": "surfaces",
"type": "int32"
},
@@ -1876,6 +1880,10 @@
"type": "pci-devfn"
},
{
+ "name": "max_outputs",
+ "type": "uint16"
+ },
+ {
"name": "surfaces",
"type": "int32"
},
diff --git a/tests/qemucapabilitiesdata/caps_2.1.1-1.caps b/tests/qemucapabilitiesdata/caps_2.1.1-1.caps
index b1ee8df..df23c28 100644
--- a/tests/qemucapabilitiesdata/caps_2.1.1-1.caps
+++ b/tests/qemucapabilitiesdata/caps_2.1.1-1.caps
@@ -167,4 +167,5 @@
<flag name='qxl-vga.vgamem_mb'/>
<flag name='pc-dimm'/>
<flag name='pci-serial'/>
+ <flag name='qxl-vga.max_outputs'/>
</qemuCaps>
diff --git a/tests/qemucapabilitiesdata/caps_2.1.1-1.replies b/tests/qemucapabilitiesdata/caps_2.1.1-1.replies
index 511461a..863003f 100644
--- a/tests/qemucapabilitiesdata/caps_2.1.1-1.replies
+++ b/tests/qemucapabilitiesdata/caps_2.1.1-1.replies
@@ -2252,6 +2252,10 @@
"type": "pci-devfn"
},
{
+ "name": "max_outputs",
+ "type": "uint16"
+ },
+ {
"name": "surfaces",
"type": "int32"
},
@@ -2322,6 +2326,10 @@
"type": "pci-devfn"
},
{
+ "name": "max_outputs",
+ "type": "uint16"
+ },
+ {
"name": "surfaces",
"type": "int32"
},
--
2.1.0
9 years, 5 months
[libvirt] [PATCH] qemu: blockcopy: Forbid using persistent bitmap granularity with raw vols
by Peter Krempa
qemu returns error but only in the event after the block job actually
starts. Reject it upfront for a better error message.
Instead of:
$ virsh blockcopy vm hdc /tmp/raw.img --granularity 4096 --verbose --wait
error: Block Copy unexpectedly failed
You will now get:
$ virsh blockcopy vm hdc /tmp/raw.img --granularity 4096 --verbose --wait
error: unsupported configuration: granularity can't be used with target volume format
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1233115
---
src/qemu/qemu_driver.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index c1373de..f570879 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -16671,6 +16671,16 @@ qemuDomainBlockCopyCommon(virDomainObjPtr vm,
goto endjob;
}
+ /* blacklist granularity with some known-bad formats */
+ if (granularity &&
+ (mirror->format == VIR_STORAGE_FILE_RAW ||
+ (mirror->format <= VIR_STORAGE_FILE_NONE &&
+ disk->src->format == VIR_STORAGE_FILE_RAW))) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("granularity can't be used with target volume format"));
+ goto endjob;
+ }
+
/* Prepare the destination file. */
/* XXX Allow non-file mirror destinations */
if (!virStorageSourceIsLocalStorage(mirror)) {
--
2.4.1
9 years, 5 months
[libvirt] [PATCH] conf: improve the way we format blkiotune and cputune
by Luyao Huang
Just refactor existing code to use a child buf instead of
check all element before format <blkiotune> and <cputune>.
This will avoid the more and more bigger element check during
we introduce new elements in <blkiotune> and <cputune> in the
future.
Signed-off-by: Luyao Huang <lhuang(a)redhat.com>
---
src/conf/domain_conf.c | 168 +++++++++++++++++++------------------------------
1 file changed, 65 insertions(+), 103 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index e592adf..466355a 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -20976,24 +20976,6 @@ virDomainHubDefFormat(virBufferPtr buf,
return 0;
}
-/*
- * Return true if no <vcpupin> specified in domain XML
- * (I.e. all vcpus inherit the cpuset from "cpuset" of
- * <vcpu>). Or false otherwise.
- */
-static bool
-virDomainIsAllVcpupinInherited(virDomainDefPtr def)
-{
- size_t i;
-
- for (i = 0; i < def->cputune.nvcpupin; i++) {
- if (!virBitmapEqual(def->cputune.vcpupin[i]->cpumask, def->cpumask))
- return false;
- }
-
- return true;
-}
-
static void
virDomainResourceDefFormat(virBufferPtr buf,
@@ -21124,8 +21106,8 @@ virDomainDefFormatInternal(virDomainDefPtr def,
const char *type = NULL;
int n;
size_t i;
- bool blkio = false;
- bool cputune = false;
+ virBuffer childrenBuf = VIR_BUFFER_INITIALIZER;
+ int indent;
virCheckFlags(VIR_DOMAIN_DEF_FORMAT_COMMON_FLAGS |
VIR_DOMAIN_DEF_FORMAT_STATUS |
@@ -21201,62 +21183,47 @@ virDomainDefFormatInternal(virDomainDefPtr def,
virBufferAsprintf(buf, "<currentMemory unit='KiB'>%llu</currentMemory>\n",
def->mem.cur_balloon);
- /* add blkiotune only if there are any */
- if (def->blkio.weight) {
- blkio = true;
- } else {
- for (n = 0; n < def->blkio.ndevices; n++) {
- if (def->blkio.devices[n].weight ||
- def->blkio.devices[n].riops ||
- def->blkio.devices[n].wiops ||
- def->blkio.devices[n].rbps ||
- def->blkio.devices[n].wbps) {
- blkio = true;
- break;
- }
- }
- }
-
- if (blkio) {
- virBufferAddLit(buf, "<blkiotune>\n");
- virBufferAdjustIndent(buf, 2);
-
- if (def->blkio.weight)
- virBufferAsprintf(buf, "<weight>%u</weight>\n",
- def->blkio.weight);
-
- for (n = 0; n < def->blkio.ndevices; n++) {
- virBlkioDevicePtr dev = &def->blkio.devices[n];
+ /* start format blkiotune */
+ indent = virBufferGetIndent(buf, false);
+ virBufferAdjustIndent(&childrenBuf, indent + 2);
+ if (def->blkio.weight)
+ virBufferAsprintf(&childrenBuf, "<weight>%u</weight>\n",
+ def->blkio.weight);
- if (!dev->weight && !dev->riops && !dev->wiops &&
- !dev->rbps && !dev->wbps)
- continue;
- virBufferAddLit(buf, "<device>\n");
- virBufferAdjustIndent(buf, 2);
- virBufferEscapeString(buf, "<path>%s</path>\n",
- dev->path);
- if (dev->weight)
- virBufferAsprintf(buf, "<weight>%u</weight>\n",
- dev->weight);
- if (dev->riops)
- virBufferAsprintf(buf, "<read_iops_sec>%u</read_iops_sec>\n",
- dev->riops);
- if (dev->wiops)
- virBufferAsprintf(buf, "<write_iops_sec>%u</write_iops_sec>\n",
- dev->wiops);
- if (dev->rbps)
- virBufferAsprintf(buf, "<read_bytes_sec>%llu</read_bytes_sec>\n",
- dev->rbps);
- if (dev->wbps)
- virBufferAsprintf(buf, "<write_bytes_sec>%llu</write_bytes_sec>\n",
- dev->wbps);
- virBufferAdjustIndent(buf, -2);
- virBufferAddLit(buf, "</device>\n");
- }
+ for (n = 0; n < def->blkio.ndevices; n++) {
+ virBlkioDevicePtr dev = &def->blkio.devices[n];
- virBufferAdjustIndent(buf, -2);
+ if (!dev->weight && !dev->riops && !dev->wiops &&
+ !dev->rbps && !dev->wbps)
+ continue;
+ virBufferAddLit(&childrenBuf, "<device>\n");
+ virBufferAdjustIndent(&childrenBuf, 2);
+ virBufferEscapeString(&childrenBuf, "<path>%s</path>\n",
+ dev->path);
+ if (dev->weight)
+ virBufferAsprintf(&childrenBuf, "<weight>%u</weight>\n",
+ dev->weight);
+ if (dev->riops)
+ virBufferAsprintf(&childrenBuf, "<read_iops_sec>%u</read_iops_sec>\n",
+ dev->riops);
+ if (dev->wiops)
+ virBufferAsprintf(&childrenBuf, "<write_iops_sec>%u</write_iops_sec>\n",
+ dev->wiops);
+ if (dev->rbps)
+ virBufferAsprintf(&childrenBuf, "<read_bytes_sec>%llu</read_bytes_sec>\n",
+ dev->rbps);
+ if (dev->wbps)
+ virBufferAsprintf(&childrenBuf, "<write_bytes_sec>%llu</write_bytes_sec>\n",
+ dev->wbps);
+ virBufferAdjustIndent(&childrenBuf, -2);
+ virBufferAddLit(&childrenBuf, "</device>\n");
+ }
+ if (virBufferUse(&childrenBuf)) {
+ virBufferAddLit(buf, "<blkiotune>\n");
+ virBufferAddBuffer(buf, &childrenBuf);
virBufferAddLit(buf, "</blkiotune>\n");
}
+ virBufferFreeAndReset(&childrenBuf);
/* add memtune only if there are any */
if (virMemoryLimitIsSet(def->mem.hard_limit) ||
@@ -21335,35 +21302,26 @@ virDomainDefFormatInternal(virDomainDefPtr def,
}
}
- if (def->cputune.sharesSpecified ||
- (def->cputune.nvcpupin && !virDomainIsAllVcpupinInherited(def)) ||
- def->cputune.period || def->cputune.quota ||
- def->cputune.emulatorpin ||
- def->cputune.emulator_period || def->cputune.emulator_quota ||
- virDomainIOThreadIDArrayHasPin(def) ||
- def->cputune.vcpusched || def->cputune.iothreadsched) {
- virBufferAddLit(buf, "<cputune>\n");
- cputune = true;
- }
-
- virBufferAdjustIndent(buf, 2);
+ /* start format cputune */
+ indent = virBufferGetIndent(buf, false);
+ virBufferAdjustIndent(&childrenBuf, indent + 2);
if (def->cputune.sharesSpecified)
- virBufferAsprintf(buf, "<shares>%lu</shares>\n",
+ virBufferAsprintf(&childrenBuf, "<shares>%lu</shares>\n",
def->cputune.shares);
if (def->cputune.period)
- virBufferAsprintf(buf, "<period>%llu</period>\n",
+ virBufferAsprintf(&childrenBuf, "<period>%llu</period>\n",
def->cputune.period);
if (def->cputune.quota)
- virBufferAsprintf(buf, "<quota>%lld</quota>\n",
+ virBufferAsprintf(&childrenBuf, "<quota>%lld</quota>\n",
def->cputune.quota);
if (def->cputune.emulator_period)
- virBufferAsprintf(buf, "<emulator_period>%llu"
+ virBufferAsprintf(&childrenBuf, "<emulator_period>%llu"
"</emulator_period>\n",
def->cputune.emulator_period);
if (def->cputune.emulator_quota)
- virBufferAsprintf(buf, "<emulator_quota>%lld"
+ virBufferAsprintf(&childrenBuf, "<emulator_quota>%lld"
"</emulator_quota>\n",
def->cputune.emulator_quota);
@@ -21373,24 +21331,24 @@ virDomainDefFormatInternal(virDomainDefPtr def,
if (virBitmapEqual(def->cpumask, def->cputune.vcpupin[i]->cpumask))
continue;
- virBufferAsprintf(buf, "<vcpupin vcpu='%u' ",
+ virBufferAsprintf(&childrenBuf, "<vcpupin vcpu='%u' ",
def->cputune.vcpupin[i]->id);
if (!(cpumask = virBitmapFormat(def->cputune.vcpupin[i]->cpumask)))
goto error;
- virBufferAsprintf(buf, "cpuset='%s'/>\n", cpumask);
+ virBufferAsprintf(&childrenBuf, "cpuset='%s'/>\n", cpumask);
VIR_FREE(cpumask);
}
if (def->cputune.emulatorpin) {
char *cpumask;
- virBufferAddLit(buf, "<emulatorpin ");
+ virBufferAddLit(&childrenBuf, "<emulatorpin ");
if (!(cpumask = virBitmapFormat(def->cputune.emulatorpin)))
goto error;
- virBufferAsprintf(buf, "cpuset='%s'/>\n", cpumask);
+ virBufferAsprintf(&childrenBuf, "cpuset='%s'/>\n", cpumask);
VIR_FREE(cpumask);
}
@@ -21401,13 +21359,13 @@ virDomainDefFormatInternal(virDomainDefPtr def,
if (!def->iothreadids[i]->cpumask)
continue;
- virBufferAsprintf(buf, "<iothreadpin iothread='%u' ",
+ virBufferAsprintf(&childrenBuf, "<iothreadpin iothread='%u' ",
def->iothreadids[i]->iothread_id);
if (!(cpumask = virBitmapFormat(def->iothreadids[i]->cpumask)))
goto error;
- virBufferAsprintf(buf, "cpuset='%s'/>\n", cpumask);
+ virBufferAsprintf(&childrenBuf, "cpuset='%s'/>\n", cpumask);
VIR_FREE(cpumask);
}
@@ -21417,13 +21375,13 @@ virDomainDefFormatInternal(virDomainDefPtr def,
if (!(ids = virBitmapFormat(sp->ids)))
goto error;
- virBufferAsprintf(buf, "<vcpusched vcpus='%s' scheduler='%s'",
+ virBufferAsprintf(&childrenBuf, "<vcpusched vcpus='%s' scheduler='%s'",
ids, virProcessSchedPolicyTypeToString(sp->policy));
VIR_FREE(ids);
if (sp->priority)
- virBufferAsprintf(buf, " priority='%d'", sp->priority);
- virBufferAddLit(buf, "/>\n");
+ virBufferAsprintf(&childrenBuf, " priority='%d'", sp->priority);
+ virBufferAddLit(&childrenBuf, "/>\n");
}
for (i = 0; i < def->cputune.niothreadsched; i++) {
@@ -21432,18 +21390,21 @@ virDomainDefFormatInternal(virDomainDefPtr def,
if (!(ids = virBitmapFormat(sp->ids)))
goto error;
- virBufferAsprintf(buf, "<iothreadsched iothreads='%s' scheduler='%s'",
+ virBufferAsprintf(&childrenBuf, "<iothreadsched iothreads='%s' scheduler='%s'",
ids, virProcessSchedPolicyTypeToString(sp->policy));
VIR_FREE(ids);
if (sp->priority)
- virBufferAsprintf(buf, " priority='%d'", sp->priority);
- virBufferAddLit(buf, "/>\n");
+ virBufferAsprintf(&childrenBuf, " priority='%d'", sp->priority);
+ virBufferAddLit(&childrenBuf, "/>\n");
}
- virBufferAdjustIndent(buf, -2);
- if (cputune)
+ if (virBufferUse(&childrenBuf)) {
+ virBufferAddLit(buf, "<cputune>\n");
+ virBufferAddBuffer(buf, &childrenBuf);
virBufferAddLit(buf, "</cputune>\n");
+ }
+ virBufferFreeAndReset(&childrenBuf);
if (virDomainNumatuneFormatXML(buf, def->numa) < 0)
goto error;
@@ -22017,6 +21978,7 @@ virDomainDefFormatInternal(virDomainDefPtr def,
error:
virBufferFreeAndReset(buf);
+ virBufferFreeAndReset(&childrenBuf);
return -1;
}
--
1.8.3.1
9 years, 5 months
[libvirt] [PATCH] qemu:lxc:xml:libxl:xen: improve the error in openconsole/channel
by Luyao Huang
We allow do not pass the dev_name to openconsole() and openchannel()
function, but the error message is not good when we do not specified
the console/channel name.
the error message after this patch:
error: internal error: character device serial0 is not using a PTY
Signed-off-by: Luyao Huang <lhuang(a)redhat.com>
---
src/libxl/libxl_driver.c | 4 ++--
src/lxc/lxc_driver.c | 3 ++-
src/qemu/qemu_driver.c | 8 ++++----
src/uml/uml_driver.c | 3 ++-
src/xen/xen_driver.c | 3 ++-
5 files changed, 12 insertions(+), 9 deletions(-)
diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c
index a7be745..c64d9be 100644
--- a/src/libxl/libxl_driver.c
+++ b/src/libxl/libxl_driver.c
@@ -4292,14 +4292,14 @@ libxlDomainOpenConsole(virDomainPtr dom,
if (!chr) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("cannot find character device %s"),
- NULLSTR(dev_name));
+ dev_name ? dev_name : "to open");
goto cleanup;
}
if (chr->source.type != VIR_DOMAIN_CHR_TYPE_PTY) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("character device %s is not using a PTY"),
- NULLSTR(dev_name));
+ dev_name ? dev_name : NULLSTR(chr->info.alias));
goto cleanup;
}
diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c
index 31fb470..cc1277b 100644
--- a/src/lxc/lxc_driver.c
+++ b/src/lxc/lxc_driver.c
@@ -3484,7 +3484,8 @@ lxcDomainOpenConsole(virDomainPtr dom,
if (chr->source.type != VIR_DOMAIN_CHR_TYPE_PTY) {
virReportError(VIR_ERR_INTERNAL_ERROR,
- _("character device %s is not using a PTY"), dev_name);
+ _("character device %s is not using a PTY"),
+ dev_name ? dev_name : NULLSTR(chr->info.alias));
goto cleanup;
}
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 6bb8549..282b32f 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -16041,14 +16041,14 @@ qemuDomainOpenConsole(virDomainPtr dom,
if (!chr) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("cannot find character device %s"),
- NULLSTR(dev_name));
+ dev_name ? dev_name : "to open");
goto cleanup;
}
if (chr->source.type != VIR_DOMAIN_CHR_TYPE_PTY) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("character device %s is not using a PTY"),
- NULLSTR(dev_name));
+ dev_name ? dev_name : NULLSTR(chr->info.alias));
goto cleanup;
}
@@ -16115,14 +16115,14 @@ qemuDomainOpenChannel(virDomainPtr dom,
if (!chr) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("cannot find channel %s"),
- NULLSTR(name));
+ name ? name : "to open");
goto cleanup;
}
if (chr->source.type != VIR_DOMAIN_CHR_TYPE_UNIX) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("channel %s is not using a UNIX socket"),
- NULLSTR(name));
+ name ? name : NULLSTR(chr->info.alias));
goto cleanup;
}
diff --git a/src/uml/uml_driver.c b/src/uml/uml_driver.c
index f09e79b..7a95458 100644
--- a/src/uml/uml_driver.c
+++ b/src/uml/uml_driver.c
@@ -2640,7 +2640,8 @@ umlDomainOpenConsole(virDomainPtr dom,
if (chr->source.type != VIR_DOMAIN_CHR_TYPE_PTY) {
virReportError(VIR_ERR_INTERNAL_ERROR,
- _("character device %s is not using a PTY"), dev_name);
+ _("character device %s is not using a PTY"),
+ dev_name ? dev_name : NULLSTR(chr->info.alias));
goto cleanup;
}
diff --git a/src/xen/xen_driver.c b/src/xen/xen_driver.c
index da9e6f4..ce31f0f 100644
--- a/src/xen/xen_driver.c
+++ b/src/xen/xen_driver.c
@@ -2705,7 +2705,8 @@ xenUnifiedDomainOpenConsole(virDomainPtr dom,
if (chr->source.type != VIR_DOMAIN_CHR_TYPE_PTY) {
virReportError(VIR_ERR_INTERNAL_ERROR,
- _("character device %s is not using a PTY"), dev_name);
+ _("character device %s is not using a PTY"),
+ dev_name ? dev_name : NULLSTR(chr->info.alias));
goto cleanup;
}
--
1.8.3.1
9 years, 5 months
[libvirt] [PATCH] conf: Adjust invalid secrettype setting during parse
by John Ferlan
Commit id '1feaccf0' attempted to handle an empty secrettype value; however,
it made a mistake by processing the secretType as if it was the original
secrettype string. The 'secretType' is actually whether 'usage' or 'uuid'
was used.
Thus adjust part of the change to make the same check for def->src->type !=
VIR_STORAGE_TYPE_VOLUME before setting auth_secret_usage from the
secrettype field.
Luckily the aforementioned commits misdeed would be overwritten by the
call to virStorageTranslateDiskSourcePool
Signed-off-by: John Ferlan <jferlan(a)redhat.com>
---
Follow up to my recent change and response, see:
http://www.redhat.com/archives/libvir-list/2015-June/msg00666.html
src/conf/domain_conf.c | 14 ++++----------
1 file changed, 4 insertions(+), 10 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index ca55981..c31edf5 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -6571,17 +6571,11 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt,
xmlStrEqual(cur->name, BAD_CAST "auth")) {
if (!(authdef = virStorageAuthDefParse(node->doc, cur)))
goto error;
- /* Shared processing code with storage pools can leave
- * this empty, but disk formatting uses it as does command
- * creation - so use the secretType to attempt to fill it in.
+ /* Disk volume types won't have the secrettype filled in until
+ * after virStorageTranslateDiskSourcePool is run
*/
- if (!authdef->secrettype) {
- const char *secrettype =
- virSecretUsageTypeToString(authdef->secretType);
- if (VIR_STRDUP(authdef->secrettype, secrettype) < 0)
- goto error;
- }
- if ((auth_secret_usage =
+ if (def->src->type != VIR_STORAGE_TYPE_VOLUME &&
+ (auth_secret_usage =
virSecretUsageTypeFromString(authdef->secrettype)) < 0) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("invalid secret type %s"),
--
2.1.0
9 years, 5 months
[libvirt] [PATCH] docs: Fix trivial copy-paste error
by Martin Kletzander
Signed-off-by: Martin Kletzander <mkletzan(a)redhat.com>
---
Pushed as trivial (in a while).
docs/formatdomain.html.in | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index 95d8c45487aa..f7b9f519a377 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -726,8 +726,7 @@
If no <code>iothreadids</code> are defined, then libvirt numbers
IOThreads from 1 to the number of <code>iothreads</code> available
for the domain. For real-time schedulers (<code>fifo</code>,
- <code>rr</code>), priority must real-time schedulers
- (<code>fifo</code>, <code>rr</code>), priority must be specified as
+ <code>rr</code>), priority must be specified as
well (and is ignored for non-real-time ones). The value range
for the priority depends on the host kernel (usually 1-99).
<span class="since">Since 1.2.13</span>
--
2.4.4
9 years, 5 months