[libvirt] [PATCH] conf: rewrite filtering for capabilities lookup
by Daniel P. Berrangé
The virCapabilitiesDomainDataLookupInternal() is given a list of
parameters representing the desired domain characteristics. It then has
to look throught the capabilities to identify an acceptable match.
The virCapsDomainDataCompare() method is used for filtering out
candidates which don't match the desired criteria. It is called
primarily from the innermost loops and as such is doing many repeated
checks. For example if architcture and os type were checked at the top
level loop the two inner loops could be avoided entirely. If emulator
and domain type were checked in the 2nd level loop the 3rd level loop
can be avoided too.
This change thus removes the virCapsDomainDataCompare() method and puts
suitable checks at the start of each loop to ensure it executes the
minimal number of loop iterations possible. The code becomes clearer to
understand as a nice side-effect.
Signed-off-by: Daniel P. Berrangé <berrange(a)redhat.com>
---
src/conf/capabilities.c | 100 ++++++++++++++++++----------------------
1 file changed, 45 insertions(+), 55 deletions(-)
diff --git a/src/conf/capabilities.c b/src/conf/capabilities.c
index 0f96500294..cfd5132329 100644
--- a/src/conf/capabilities.c
+++ b/src/conf/capabilities.c
@@ -604,46 +604,6 @@ virCapabilitiesHostSecModelAddBaseLabel(virCapsHostSecModelPtr secmodel,
return -1;
}
-static bool
-virCapsDomainDataCompare(virCapsGuestPtr guest,
- virCapsGuestDomainPtr domain,
- virCapsGuestMachinePtr machine,
- int ostype,
- virArch arch,
- virDomainVirtType domaintype,
- const char *emulator,
- const char *machinetype)
-{
- const char *check_emulator = NULL;
-
- if (ostype != -1 && guest->ostype != ostype)
- return false;
- if ((arch != VIR_ARCH_NONE) && (guest->arch.id != arch))
- return false;
-
- if (domaintype != VIR_DOMAIN_VIRT_NONE &&
- (!domain || domain->type != domaintype))
- return false;
-
- if (emulator) {
- if (domain)
- check_emulator = domain->info.emulator;
- if (!check_emulator)
- check_emulator = guest->arch.defaultInfo.emulator;
- if (STRNEQ_NULLABLE(check_emulator, emulator))
- return false;
- }
-
- if (machinetype) {
- if (!machine)
- return false;
- if (STRNEQ(machine->name, machinetype) &&
- (STRNEQ_NULLABLE(machine->canonical, machinetype)))
- return false;
- }
-
- return true;
-}
static virCapsDomainDataPtr
virCapabilitiesDomainDataLookupInternal(virCapsPtr caps,
@@ -659,13 +619,45 @@ virCapabilitiesDomainDataLookupInternal(virCapsPtr caps,
virCapsDomainDataPtr ret = NULL;
size_t i, j, k;
+ VIR_DEBUG("Lookup ostype=%d arch=%d domaintype=%d emulator=%s machine=%s",
+ ostype, arch, domaintype, NULLSTR(emulator), NULLSTR(machinetype));
for (i = 0; i < caps->nguests; i++) {
virCapsGuestPtr guest = caps->guests[i];
+ if (ostype != -1 && guest->ostype != ostype) {
+ VIR_DEBUG("Skip os type want=%d vs got=%d", ostype, guest->ostype);
+ continue;
+ }
+ VIR_DEBUG("Match os type %d", ostype);
+
+ if ((arch != VIR_ARCH_NONE) && (guest->arch.id != arch)) {
+ VIR_DEBUG("Skip arch want=%d vs got=%d", arch, guest->arch.id);
+ continue;
+ }
+ VIR_DEBUG("Match arch %d", arch);
+
for (j = 0; j < guest->arch.ndomains; j++) {
virCapsGuestDomainPtr domain = guest->arch.domains[j];
virCapsGuestMachinePtr *machinelist;
int nmachines;
+ const char *check_emulator = NULL;
+
+ if (domaintype != VIR_DOMAIN_VIRT_NONE &&
+ (domain->type != domaintype)) {
+ VIR_DEBUG("Skip domain type want=%d vs got=%d", domaintype, domain->type);
+ continue;
+ }
+ VIR_DEBUG("Match domain type %d", domaintype);
+
+ check_emulator = domain->info.emulator;
+ if (!check_emulator)
+ check_emulator = guest->arch.defaultInfo.emulator;
+ if (emulator && STRNEQ_NULLABLE(check_emulator, emulator)) {
+ VIR_DEBUG("Skip emulator got=%s vs want=%s",
+ emulator, NULLSTR(check_emulator));
+ continue;
+ }
+ VIR_DEBUG("Match emulator %s", NULLSTR(emulator));
if (domain->info.nmachines) {
nmachines = domain->info.nmachines;
@@ -677,32 +669,29 @@ virCapabilitiesDomainDataLookupInternal(virCapsPtr caps,
for (k = 0; k < nmachines; k++) {
virCapsGuestMachinePtr machine = machinelist[k];
- if (!virCapsDomainDataCompare(guest, domain, machine,
- ostype, arch, domaintype,
- emulator, machinetype))
+
+ if (machinetype &&
+ STRNEQ(machine->name, machinetype) &&
+ STRNEQ_NULLABLE(machine->canonical, machinetype)) {
+ VIR_DEBUG("Skip machine type want=%s vs got=%s got=%s",
+ machinetype, machine->name, NULLSTR(machine->canonical));
continue;
+ }
+ VIR_DEBUG("Match machine type machine %s\n", NULLSTR(machinetype));
foundmachine = machine;
break;
}
- if (!foundmachine) {
- if (!virCapsDomainDataCompare(guest, domain, NULL,
- ostype, arch, domaintype,
- emulator, machinetype))
- continue;
- }
+ if (!foundmachine && nmachines)
+ continue;
founddomain = domain;
break;
}
- if (!founddomain) {
- if (!virCapsDomainDataCompare(guest, NULL, NULL,
- ostype, arch, domaintype,
- emulator, machinetype))
- continue;
- }
+ if (!founddomain)
+ continue;
foundguest = guest;
break;
@@ -731,6 +720,7 @@ virCapabilitiesDomainDataLookupInternal(virCapsPtr caps,
goto error;
}
+ VIR_DEBUG("No match %s", virBufferCurrentContent(&buf));
virReportError(VIR_ERR_INVALID_ARG,
_("could not find capabilities for %s"),
virBufferCurrentContent(&buf));
--
2.17.1
6 years, 3 months
[libvirt] [jenkins-ci PATCH] projects: Don't use ~/rpmbuild for osinfo-db
by Andrea Bolognani
Commit 15a19dbc0b73 made sure all explicit calls use
the current directory instead of ~/rpmbuild as workspace,
but osinfo-db wasn't affected by the change since its
build recipe calls the custom 'make rpm' target and
continued storing build artifacts in ~/rpmbuild.
Signed-off-by: Andrea Bolognani <abologna(a)redhat.com>
---
projects/osinfo-db.yaml | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/projects/osinfo-db.yaml b/projects/osinfo-db.yaml
index 141a373..d154c98 100644
--- a/projects/osinfo-db.yaml
+++ b/projects/osinfo-db.yaml
@@ -19,7 +19,5 @@
parent_jobs: 'osinfo-db-master-check'
machines: '{rpm_machines}'
command: |
- rm -f *.tar.{archive_format}
- $MAKE osinfo-db.spec
perl -i -p -e 's/BuildRequires: osinfo-db-tools.*//' osinfo-db.spec
- $MAKE rpm
+ rpmbuild --clean --define "_topdir `pwd`/rpmbuild" --define "_sourcedir `pwd`" -ba osinfo-db.spec
--
2.17.1
6 years, 3 months
[libvirt] [jenkins-ci PATCH] jobs: ensure rpmbuild purges $RPM-ROOT/BUILD/$PACKAGE
by Daniel P. Berrangé
When using 'rpmbuild --rebuild', $RPM-ROOT/BUILD/$PACKAGE is
automatically deleted on completion, but when using 'rpmbuild --ta' it
is not deleted. We need to pass --clean to get the desired behaviour.
This was not a visible problem in the past because "git clean -fdx"
would purge the directory, but since we use %autosetup now the directory
will contain a git repo which causes "git clean" to skip deletion:
$ su - jenkins
$ cd libvirt-master
$ git clean -fdx
Skipping repository build/rpmbuild/BUILD/libvirt-4.7.0
Signed-off-by: Daniel P. Berrangé <berrange(a)redhat.com>
---
jobs/autotools.yaml | 2 +-
jobs/perl-modulebuild.yaml | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/jobs/autotools.yaml b/jobs/autotools.yaml
index c1d0f27..f1ebf7b 100644
--- a/jobs/autotools.yaml
+++ b/jobs/autotools.yaml
@@ -172,7 +172,7 @@
sed -i -e 's/BuildRequires: pkgconfig(libvirt.*).*//' {name}.spec
rm -f *.tar.{archive_format}
$MAKE dist
- rpmbuild --define "_topdir `pwd`/rpmbuild" -ta {name}-*.tar.{archive_format}
+ rpmbuild --clean --define "_topdir `pwd`/rpmbuild" -ta {name}-*.tar.{archive_format}
publishers:
- email:
recipients: '{obj:spam}'
diff --git a/jobs/perl-modulebuild.yaml b/jobs/perl-modulebuild.yaml
index 934b216..3f3f537 100644
--- a/jobs/perl-modulebuild.yaml
+++ b/jobs/perl-modulebuild.yaml
@@ -126,7 +126,7 @@
sed -i -e 's/BuildRequires: *libvirt.*devel.*//' *.spec
rm -f *.tar.{archive_format}
perl Build dist
- rpmbuild --define "_topdir `pwd`/rpmbuild" -ta *.tar.{archive_format}
+ rpmbuild --clean --define "_topdir `pwd`/rpmbuild" -ta *.tar.{archive_format}
publishers:
- email:
recipients: '{obj:spam}'
--
2.17.1
6 years, 3 months
[libvirt] [jenkins-ci PATCH 00/12] lcitool: Add 'build' action
by Andrea Bolognani
Also known as [secret feature redacted] :)
This will be mostly useful for developers wanting to validate their
changes locally before posting patches, but it will also allow
CentOS CI maintainers to prime new guests before adding them to
Jenkins, thus avoiding the usual dance of starting and cancelling
several builds manually.
We duplicate quite a bit of information to implement this: that's
unfortunate, and I'll be looking into ways to get rid of such
duplication down the line, but IMHO the feature is useful enough
that it's better to have it out there in its current state rather
than witholding it until a less verbose implementation has been
figured out.
Dependencies between projects are still missing, so if you want to
build eg. libvirt-glib you'll have to take care of building libvirt
first yourself or face a failure.
The first few patches (1-5) tweak the Jenkins jobs and projects to
bring them to a point where they can be translated into Ansible
tasks almost verbatim; the remaining ones perform such translation
and implement the necessary Python glue.
Andrea Bolognani (12):
projects: Add default machines for libvirt-dbus
jobs: Rename git-url -> git_url
jobs: Remove archive_format from defaults
jobs: Move some parameters from jobs to defaults
jobs: Declare empty values consistently
guests: Add build jobs
guests: Add build projects
guests: Add build playbook
lcitool: make playbook execution generic
lcitool: Add 'build' action
lcitool: Support building arbitrary branches
lcitool: Document build action
guests/README.markdown | 19 +++
guests/lcitool | 109 ++++++++++--------
.../build/jobs/autotools-build-job.yml | 15 +++
.../build/jobs/autotools-check-job.yml | 16 +++
.../build/jobs/autotools-rpm-job.yml | 17 +++
.../build/jobs/autotools-syntax-check-job.yml | 12 ++
guests/playbooks/build/jobs/defaults.yml | 33 ++++++
.../build/jobs/generic-build-job.yml | 11 ++
.../build/jobs/generic-check-job.yml | 11 ++
.../playbooks/build/jobs/generic-rpm-job.yml | 11 ++
.../build/jobs/generic-syntax-check-job.yml | 11 ++
guests/playbooks/build/jobs/go-build-job.yml | 11 ++
guests/playbooks/build/jobs/go-check-job.yml | 11 ++
.../build/jobs/perl-modulebuild-build-job.yml | 13 +++
.../build/jobs/perl-modulebuild-check-job.yml | 11 ++
.../build/jobs/perl-modulebuild-rpm-job.yml | 16 +++
guests/playbooks/build/jobs/prepare.yml | 19 +++
.../build/jobs/python-distutils-build-job.yml | 13 +++
.../build/jobs/python-distutils-check-job.yml | 11 ++
.../build/jobs/python-distutils-rpm-job.yml | 12 ++
guests/playbooks/build/main.yml | 16 +++
guests/playbooks/build/projects/libosinfo.yml | 36 ++++++
.../playbooks/build/projects/libvirt-cim.yml | 10 ++
.../playbooks/build/projects/libvirt-dbus.yml | 28 +++++
.../playbooks/build/projects/libvirt-glib.yml | 38 ++++++
.../build/projects/libvirt-go-xml.yml | 13 +++
.../playbooks/build/projects/libvirt-go.yml | 13 +++
.../playbooks/build/projects/libvirt-perl.yml | 19 +++
.../build/projects/libvirt-python.yml | 13 +++
.../build/projects/libvirt-sandbox.yml | 23 ++++
.../playbooks/build/projects/libvirt-tck.yml | 23 ++++
guests/playbooks/build/projects/libvirt.yml | 52 +++++++++
.../build/projects/osinfo-db-tools.yml | 36 ++++++
guests/playbooks/build/projects/osinfo-db.yml | 25 ++++
.../playbooks/build/projects/virt-manager.yml | 34 ++++++
.../playbooks/build/projects/virt-viewer.yml | 38 ++++++
jobs/autotools.yaml | 3 +-
jobs/defaults.yaml | 8 +-
jobs/generic.yaml | 3 +-
jobs/go.yaml | 3 +-
jobs/perl-modulebuild.yaml | 3 +-
jobs/python-distutils.yaml | 3 +-
projects/libosinfo.yaml | 3 +-
projects/libvirt-cim.yaml | 3 +-
projects/libvirt-dbus.yaml | 18 +--
projects/libvirt-glib.yaml | 3 +-
projects/libvirt-go-xml.yaml | 3 +-
projects/libvirt-go.yaml | 3 +-
projects/libvirt-perl.yaml | 3 +-
projects/libvirt-python.yaml | 3 +-
projects/libvirt-sandbox.yaml | 3 +-
projects/libvirt-tck.yaml | 3 +-
projects/libvirt.yaml | 2 +-
projects/osinfo-db-tools.yaml | 3 +-
projects/osinfo-db.yaml | 2 +-
projects/virt-manager.yaml | 3 +-
projects/virt-viewer.yaml | 3 +-
57 files changed, 798 insertions(+), 82 deletions(-)
create mode 100644 guests/playbooks/build/jobs/autotools-build-job.yml
create mode 100644 guests/playbooks/build/jobs/autotools-check-job.yml
create mode 100644 guests/playbooks/build/jobs/autotools-rpm-job.yml
create mode 100644 guests/playbooks/build/jobs/autotools-syntax-check-job.yml
create mode 100644 guests/playbooks/build/jobs/defaults.yml
create mode 100644 guests/playbooks/build/jobs/generic-build-job.yml
create mode 100644 guests/playbooks/build/jobs/generic-check-job.yml
create mode 100644 guests/playbooks/build/jobs/generic-rpm-job.yml
create mode 100644 guests/playbooks/build/jobs/generic-syntax-check-job.yml
create mode 100644 guests/playbooks/build/jobs/go-build-job.yml
create mode 100644 guests/playbooks/build/jobs/go-check-job.yml
create mode 100644 guests/playbooks/build/jobs/perl-modulebuild-build-job.yml
create mode 100644 guests/playbooks/build/jobs/perl-modulebuild-check-job.yml
create mode 100644 guests/playbooks/build/jobs/perl-modulebuild-rpm-job.yml
create mode 100644 guests/playbooks/build/jobs/prepare.yml
create mode 100644 guests/playbooks/build/jobs/python-distutils-build-job.yml
create mode 100644 guests/playbooks/build/jobs/python-distutils-check-job.yml
create mode 100644 guests/playbooks/build/jobs/python-distutils-rpm-job.yml
create mode 100644 guests/playbooks/build/main.yml
create mode 100644 guests/playbooks/build/projects/libosinfo.yml
create mode 100644 guests/playbooks/build/projects/libvirt-cim.yml
create mode 100644 guests/playbooks/build/projects/libvirt-dbus.yml
create mode 100644 guests/playbooks/build/projects/libvirt-glib.yml
create mode 100644 guests/playbooks/build/projects/libvirt-go-xml.yml
create mode 100644 guests/playbooks/build/projects/libvirt-go.yml
create mode 100644 guests/playbooks/build/projects/libvirt-perl.yml
create mode 100644 guests/playbooks/build/projects/libvirt-python.yml
create mode 100644 guests/playbooks/build/projects/libvirt-sandbox.yml
create mode 100644 guests/playbooks/build/projects/libvirt-tck.yml
create mode 100644 guests/playbooks/build/projects/libvirt.yml
create mode 100644 guests/playbooks/build/projects/osinfo-db-tools.yml
create mode 100644 guests/playbooks/build/projects/osinfo-db.yml
create mode 100644 guests/playbooks/build/projects/virt-manager.yml
create mode 100644 guests/playbooks/build/projects/virt-viewer.yml
--
2.17.1
6 years, 3 months
[libvirt] [PATCH libvirt-tck] Cleanup secret in disk encryption test
by Jim Fehlig
100-disk-encryption.t does not undefine the secret it defines
for the test disk, causing subsequent runs of the test to fail
not ok 1 - secret created
Failed test 'secret created'
at /usr/share/libvirt-tck/tests/qemu/100-disk-encryption.t line 65.
died: Sys::Virt::Error (libvirt error code: 1, message: internal error: a
secret with UUID 212c459b-b02c-41fc-8ae2-714cc31612c5 is already defined
for use with /var/cache/libvirt-tck/300-disk-encryption/demo.qcow2
Signed-off-by: Jim Fehlig <jfehlig(a)suse.com>
---
scripts/qemu/100-disk-encryption.t | 2 ++
1 file changed, 2 insertions(+)
diff --git a/scripts/qemu/100-disk-encryption.t b/scripts/qemu/100-disk-encryption.t
index 32e2adf..1a36650 100644
--- a/scripts/qemu/100-disk-encryption.t
+++ b/scripts/qemu/100-disk-encryption.t
@@ -118,3 +118,5 @@ $dom->undefine;
ok_error(sub { $conn->get_domain_by_name("tck") }, "NO_DOMAIN error raised from missing domain", 42);
}
+
+$secret->undefine;
--
2.18.0
6 years, 3 months
[libvirt] [PATCH] storage: tweak error message when skipping file
by Daniel P. Berrangé
Signed-off-by: Daniel P. Berrangé <berrange(a)redhat.com>
---
src/storage/storage_util.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/storage/storage_util.c b/src/storage/storage_util.c
index 715d5c2f88..42a9b6abf0 100644
--- a/src/storage/storage_util.c
+++ b/src/storage/storage_util.c
@@ -3609,8 +3609,8 @@ virStorageBackendRefreshLocal(virStoragePoolObjPtr pool)
int err;
if (virStringHasControlChars(ent->d_name)) {
- VIR_WARN("Ignoring file with control characters under '%s'",
- def->target.path);
+ VIR_WARN("Ignoring file '%s' with control characters under '%s'",
+ ent->d_name, def->target.path);
continue;
}
--
2.17.1
6 years, 3 months
[libvirt] [PATCH 0/9] iSCSI fixes and improvements
by Pavel Hrdina
Pavel Hrdina (9):
docs: fix iscsi-direct XML example
conf: properly translate iscsi-direct storage pool
conf: rename and move virStoragePoolSourceInitiatorAttr
util: introduce virStorageSourceInitiator functions
conf: use virStorageSourceInitiator functions
docs: move storage initiator def into storagecommon.rng
conf: introduce initiator IQN support for domain disks
tests: introduce qemu disk-network-iscsi-modern test cases
qemu: add support for domain disk initiator IQN
docs/formatdomain.html.in | 20 +++++
docs/schemas/domaincommon.rng | 3 +
docs/schemas/storagecommon.rng | 11 +++
docs/schemas/storagepool.rng | 11 ---
docs/storage.html.in | 6 +-
src/conf/domain_conf.c | 71 +++++++++++++-----
src/conf/storage_conf.c | 16 ++--
src/conf/storage_conf.h | 7 +-
src/qemu/qemu_block.c | 2 +
src/qemu/qemu_domain.c | 9 +++
src/util/virstoragefile.c | 39 ++++++++++
src/util/virstoragefile.h | 23 ++++++
.../disk-network-iscsi-modern.args | 58 ++++++++++++++
.../disk-network-iscsi-modern.xml | 75 +++++++++++++++++++
tests/qemuxml2argvtest.c | 4 +
15 files changed, 306 insertions(+), 49 deletions(-)
create mode 100644 tests/qemuxml2argvdata/disk-network-iscsi-modern.args
create mode 100644 tests/qemuxml2argvdata/disk-network-iscsi-modern.xml
--
2.17.1
6 years, 3 months
[libvirt] [PATCH] qemu: ensure default machine types don't change if QEMU changes
by Daniel P. Berrangé
It is increasingly likely that some distro is going to change the
default "x86" machine type in QEMU from "pc" to "q35". This will
certainly break existing applications which write their XML on the
assumption that it is using a "pc" machine by default. For example they'll
lack a IDE CDROM and get PCIe instead of PCI which changes the topology
radically.
Libvirt promises to isolate applications from hypervisor changes that
may cause incompatibilities, so we must ensure that we always use the
"pc" machine type if it is available. Only use QEMU's own reported
default machine type if "pc" does not exist.
This issue is not x86-only, other arches are liable t change their
default machine, while some arches don't report any default at all
causing libvirt to pick the first machine in the list. Thus to
guarantee stability to applications, declare a preferred default
machine for all architectures we currently support with QEMU.
Note this change assumes there will always be a "pc" alias as long as a
versioned "pc-XXX" machine type exists. If QEMU were to ship a "pc-XXX"
machine type but not provide the "pc" alias, it is too hard to decide
which to default so. Versioned machine types are supposed to be
considered opaque strings, so we can't apply any sensible ordering
ourselves and QEMU isn't reporting the list of machines in any sensible
ordering itself.
Signed-off-by: Daniel P. Berrangé <berrange(a)redhat.com>
---
src/qemu/qemu_capabilities.c | 79 ++++++++++++++++++++++++++++++++++--
1 file changed, 76 insertions(+), 3 deletions(-)
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index 0fb800589a..045e2bd489 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -2233,6 +2233,61 @@ virQEMUCapsProbeQMPDevices(virQEMUCapsPtr qemuCaps,
}
+/* Historically QEMU x86 targets defaulted to 'pc' machine type but
+ * in future x86_64 might switch 'q35'. Such a change is considered
+ * an ABI break from libvirt's POV. Other QEMU targets may not declare
+ * a default macine at all, causing libvirt to use the first reported
+ * machinbe in the list.
+ *
+ * Here we record a preferred default machine for all arches, so
+ * that we're not vulnerable to changes in QEMU defaults or machine
+ * list ordering.
+ */
+static const char *preferredMachines[VIR_ARCH_LAST] =
+{
+ [VIR_ARCH_ALPHA] = "clipper",
+ [VIR_ARCH_ARMV6L] = NULL, /* No QEMU impl */
+ [VIR_ARCH_ARMV7L] = "integratorcp",
+ [VIR_ARCH_ARMV7B] = "integratorcp",
+
+ [VIR_ARCH_AARCH64] = "integratorcp",
+ [VIR_ARCH_CRIS] = "axis-dev88",
+ [VIR_ARCH_I686] = "pc",
+ [VIR_ARCH_ITANIUM] = NULL, /* doesn't exist in QEMU any more */
+ [VIR_ARCH_LM32] = "lm32-evr",
+
+ [VIR_ARCH_M68K] = "mcf5208evb",
+ [VIR_ARCH_MICROBLAZE] = "petalogix-s3adsp1800",
+ [VIR_ARCH_MICROBLAZEEL] = "petalogix-s3adsp1800",
+ [VIR_ARCH_MIPS] = "malta",
+ [VIR_ARCH_MIPSEL] = "malta",
+
+ [VIR_ARCH_MIPS64] = "malta",
+ [VIR_ARCH_MIPS64EL] = "malta",
+ [VIR_ARCH_OR32] = "or1k-sim",
+ [VIR_ARCH_PARISC] = NULL, /* No QEMU impl */
+ [VIR_ARCH_PARISC64] = NULL, /* No QEMU impl */
+
+ [VIR_ARCH_PPC] = "g3beige",
+ [VIR_ARCH_PPCLE] = "g3beige",
+ [VIR_ARCH_PPC64] = "pseries",
+ [VIR_ARCH_PPC64LE] = "pseries",
+ [VIR_ARCH_PPCEMB] = "bamboo",
+
+ [VIR_ARCH_S390] = NULL, /* No QEMU impl*/
+ [VIR_ARCH_S390X] = "s390-ccw-virtio",
+ [VIR_ARCH_SH4] = "shix",
+ [VIR_ARCH_SH4EB] = "shix",
+ [VIR_ARCH_SPARC] = "SS-5",
+
+ [VIR_ARCH_SPARC64] = "sun4u",
+ [VIR_ARCH_UNICORE32] = "puv3",
+ [VIR_ARCH_X86_64] = "pc",
+ [VIR_ARCH_XTENSA] = "sim",
+ [VIR_ARCH_XTENSAEB] = "sim",
+
+};
+
static int
virQEMUCapsProbeQMPMachineTypes(virQEMUCapsPtr qemuCaps,
qemuMonitorPtr mon)
@@ -2241,7 +2296,9 @@ virQEMUCapsProbeQMPMachineTypes(virQEMUCapsPtr qemuCaps,
int nmachines = 0;
int ret = -1;
size_t i;
- size_t defIdx = 0;
+ ssize_t defIdx = -1;
+ ssize_t preferredIdx = -1;
+ const char *preferredMachine = preferredMachines[qemuCaps->arch];
if ((nmachines = qemuMonitorGetMachines(mon, &machines)) < 0)
return -1;
@@ -2263,12 +2320,28 @@ virQEMUCapsProbeQMPMachineTypes(virQEMUCapsPtr qemuCaps,
mach->maxCpus = machines[i]->maxCpus;
mach->hotplugCpus = machines[i]->hotplugCpus;
+ if (preferredMachine &&
+ (STREQ_NULLABLE(mach->alias, preferredMachine) ||
+ STREQ(mach->name, preferredMachine)))
+ preferredIdx = qemuCaps->nmachineTypes - 1;
+
if (machines[i]->isDefault)
defIdx = qemuCaps->nmachineTypes - 1;
}
- if (defIdx)
- virQEMUCapsSetDefaultMachine(qemuCaps, defIdx);
+ /*
+ * We'll prefer to use our own historical default machine
+ * to avoid mgmt apps seeing semantics changes when QEMU
+ * alters it defaults.
+ *
+ * Our preferred pmachine might have been compiled out of
+ * QEMU at build time though, so we still fallback to honouring
+ * QEMU's reported default in that case
+ */
+ if (preferredIdx == -1)
+ preferredIdx = defIdx;
+ if (preferredIdx != -1)
+ virQEMUCapsSetDefaultMachine(qemuCaps, preferredIdx);
ret = 0;
--
2.17.1
6 years, 3 months
[libvirt] [PATCH v3] conf: virDomainDefValidateInternal prohibit some characters in shmem name
by Simon Kobyda
Validate that the provided XML shmem name is not directory specific "."
or ".." names as well as ensuring that there is no path separator '/' in
the name.
https://bugzilla.redhat.com/show_bug.cgi?id=1192400
Signed-off-by: Simon Kobyda <skobyda(a)redhat.com>
---
Changes in v3:
- moved the functionality to virDomainDeviceDefValidateInternal
- documented changes in docs/formatdomain.html.in
docs/formatdomain.html.in | 4 +++-
src/conf/domain_conf.c | 29 ++++++++++++++++++++++++++++-
2 files changed, 31 insertions(+), 2 deletions(-)
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index a3afe137bf..f18ca6fc64 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -8017,7 +8017,9 @@ qemu-kvm -net nic,model=? /dev/null
<dt><code>shmem</code></dt>
<dd>
The <code>shmem</code> element has one mandatory attribute,
- <code>name</code> to identify the shared memory.
+ <code>name</code> to identify the shared memory. This attribute cannot
+ be directory specific to <code>.</code> or <code>..</code> as well as
+ it cannot involve path separator <code>/</code>.
</dd>
<dt><code>model</code></dt>
<dd>
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 7ab2953d83..415c03c56f 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -5696,6 +5696,31 @@ virDomainVsockDefValidate(const virDomainVsockDef *vsock)
}
+static int
+virDomainShmemDefValidate(const virDomainShmemDef *shmem)
+{
+ if (strchr(shmem->name, '/')) {
+ virReportError(VIR_ERR_XML_ERROR, "%s",
+ _("shmem name cannot include '/' character"));
+ return -1;
+ }
+
+ if (STREQ(shmem->name, ".")) {
+ virReportError(VIR_ERR_XML_ERROR, "%s",
+ _("shmem name cannot be equal to '.'"));
+ return -1;
+ }
+
+ if (STREQ(shmem->name, "..")) {
+ virReportError(VIR_ERR_XML_ERROR, "%s",
+ _("shmem name cannot be equal to '..'"));
+ return -1;
+ }
+
+ return 0;
+}
+
+
static int
virDomainDeviceDefValidateInternal(const virDomainDeviceDef *dev,
const virDomainDef *def)
@@ -5734,6 +5759,9 @@ virDomainDeviceDefValidateInternal(const virDomainDeviceDef *dev,
case VIR_DOMAIN_DEVICE_VSOCK:
return virDomainVsockDefValidate(dev->data.vsock);
+ case VIR_DOMAIN_DEVICE_SHMEM:
+ return virDomainShmemDefValidate(dev->data.shmem);
+
case VIR_DOMAIN_DEVICE_LEASE:
case VIR_DOMAIN_DEVICE_FS:
case VIR_DOMAIN_DEVICE_INPUT:
@@ -5743,7 +5771,6 @@ virDomainDeviceDefValidateInternal(const virDomainDeviceDef *dev,
case VIR_DOMAIN_DEVICE_HUB:
case VIR_DOMAIN_DEVICE_MEMBALLOON:
case VIR_DOMAIN_DEVICE_NVRAM:
- case VIR_DOMAIN_DEVICE_SHMEM:
case VIR_DOMAIN_DEVICE_TPM:
case VIR_DOMAIN_DEVICE_PANIC:
case VIR_DOMAIN_DEVICE_IOMMU:
--
2.17.1
6 years, 3 months