[libvirt] [PATCH] qemu: report a nicer error when USB is disabled
by Ján Tomko
If the user tries to define a domain that has
<controller type='usb' model='none'/>
and also some USB devices, we report an error:
error: internal error: No free USB ports
Which is technically still correct for a domain with no USB ports.
Change it to:
USB is disabled for this domain, but USB devices are present in the domain XML
https://bugzilla.redhat.com/show_bug.cgi?id=1347550
---
src/conf/domain_conf.c | 2 +-
src/conf/domain_conf.h | 2 ++
src/libvirt_private.syms | 1 +
src/qemu/qemu_domain_address.c | 7 +++++++
4 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index f3b4dd33d..028fcb5be 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -5116,7 +5116,7 @@ virDomainDiskDefValidate(const virDomainDiskDef *disk)
return 0;
}
-static bool
+bool
virDomainDefHasUSB(const virDomainDef *def)
{
size_t i;
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index bb3b6f0c3..32e191e0a 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -2656,6 +2656,8 @@ int virDomainDefPostParse(virDomainDefPtr def,
unsigned int parseFlags,
virDomainXMLOptionPtr xmlopt,
void *parseOpaque);
+bool
+virDomainDefHasUSB(const virDomainDef *def);
int virDomainDefValidate(virDomainDefPtr def,
virCapsPtr caps,
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 5b1bc5e4f..21f226258 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -267,6 +267,7 @@ virDomainDefGetVcpusTopology;
virDomainDefHasDeviceAddress;
virDomainDefHasMemballoon;
virDomainDefHasMemoryHotplug;
+virDomainDefHasUSB;
virDomainDefHasVcpusOffline;
virDomainDefMaybeAddController;
virDomainDefMaybeAddInput;
diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c
index 69c0c8bf2..0d565b3ea 100644
--- a/src/qemu/qemu_domain_address.c
+++ b/src/qemu/qemu_domain_address.c
@@ -2644,6 +2644,13 @@ qemuDomainUSBAddressAddHubs(virDomainDefPtr def)
&data,
false));
+ if (data.count && !virDomainDefHasUSB(def)) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("USB is disabled for this domain, but USB devices "
+ "are present in the domain XML"));
+ return -1;
+ }
+
if (data.count > available_ports)
hubs_needed = VIR_DIV_UP(data.count - available_ports + 1,
VIR_DOMAIN_USB_HUB_PORTS - 1);
--
2.13.0
6 years, 9 months
[libvirt] [PATCH] Migration: Preserve the failed job in case migration job is terminated beyond the perform phase.
by Prerna Saxena
In case of non-p2p migration, in case libvirt client gets disconnected from source libvirt
after PERFORM phase is over, the daemon just resets the current migration job.
However, the VM could be left paused on both source and destination in such case. In case
the client reconnects and queries migration status, the job has been blanked out from source libvirt,
and this reconnected client has no clear way of figuring out if an unclean migration had previously
been aborted.
This patch calls out a "potentially" incomplete migration as a failed job, so that a client may
be able to watch previously failed jobs for this VM and take corrective actions as needed.
Signed-off-by: Prerna Saxena <saxenap.ltc(a)gmail.com>
---
src/qemu/qemu_domain.c | 16 ++++++++++++++++
src/qemu/qemu_domain.h | 2 ++
src/qemu/qemu_migration.c | 4 ++--
3 files changed, 20 insertions(+), 2 deletions(-)
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index e8e0313..7c60d17 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -4564,6 +4564,22 @@ qemuDomainObjDiscardAsyncJob(virQEMUDriverPtr driver, virDomainObjPtr obj)
qemuDomainObjSaveJob(driver, obj);
}
+
+void
+qemuDomainObjFailAsyncJob(virQEMUDriverPtr driver, virDomainObjPtr obj)
+{
+ qemuDomainObjPrivatePtr priv = obj->privateData;
+ VIR_FREE(priv->job.completed);
+ if (VIR_ALLOC(priv->job.completed) == 0) {
+ priv->job.current->type = VIR_DOMAIN_JOB_FAILED;
+ priv->job.completed = priv->job.current;
+ } else {
+ VIR_WARN("Unable to allocate job.completed for VM %s", obj->def->name);
+ }
+ qemuDomainObjResetAsyncJob(priv);
+ qemuDomainObjEndJob(driver, obj);
+}
+
void
qemuDomainObjReleaseAsyncJob(virDomainObjPtr obj)
{
diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h
index c33af36..6465603 100644
--- a/src/qemu/qemu_domain.h
+++ b/src/qemu/qemu_domain.h
@@ -497,6 +497,8 @@ void qemuDomainObjRestoreJob(virDomainObjPtr obj,
struct qemuDomainJobObj *job);
void qemuDomainObjDiscardAsyncJob(virQEMUDriverPtr driver,
virDomainObjPtr obj);
+void qemuDomainObjFailAsyncJob(virQEMUDriverPtr driver,
+ virDomainObjPtr obj);
void qemuDomainObjReleaseAsyncJob(virDomainObjPtr obj);
qemuMonitorPtr qemuDomainGetMonitor(virDomainObjPtr vm)
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index 69eb231..fd8950e 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -1911,8 +1911,8 @@ qemuMigrationCleanup(virDomainObjPtr vm,
VIR_WARN("Migration of domain %s finished but we don't know if the"
" domain was successfully started on destination or not",
vm->def->name);
- /* clear the job and let higher levels decide what to do */
- qemuDomainObjDiscardAsyncJob(driver, vm);
+ /* clearly "fail" the job and let higher levels decide what to do */
+ qemuDomainObjFailAsyncJob(driver, vm);
break;
case QEMU_MIGRATION_PHASE_PERFORM3:
--
1.7.1
6 years, 9 months
[libvirt] Ask question
by 李杰
Dear
Recently,I am interested in libvirt,but I found the libvirt does't support revert and delete the external snapshot which the raw disk based guest.My libvirt and qemu release are both 3.2.0.So I have a question,the community how to solve it,if have any plans about it.Can you tell me more about it?Thank you very much.
Best Regards
Rambo
6 years, 9 months
[libvirt] [PATCH 0/7] Keep non-persistent changes alive in snapshot
by Kothapally Madhu Pavan
Restoring to a snapshot should not overwrite the persistent XML configuration
of a snapshot as a side effect. This patchset fixes the same. Currently,
virDomainSnapshotDef only saves active domain definition of the guest.
And on restore the active domain definition is used as both active and
inactive domain definitions. This will make the non-persistent changes
persistent in snapshot image. This patchset allows to save inactive domain
definition as well and on snapshot-revert non-persistent configuration is
restored as is.
Currently, snapshot-revert is making non-presistent changes as persistent.
Here are the steps to reproduce.
Step1: virsh define $dom
Step2: virsh attach-device $dom $memory-device.xml --live
Step3: virsh snapshot-create $dom
Step4: virsh destroy $dom
Step5: virsh snapshot-revert $dom $snapshot-name
Step6: virsh destroy $dom
Step7: virsh start $dom
Here we still have $memory-device attached in Step2.
This patchset is attempting to solve this issue. This patchset will also
allow user to dump and edit inactive XML configuration of a snapshot.
Dumping inactive domain definition of a snapshot is important as
--redefine uses snapshot-dumpxml output to redefine a snapshot.
Kothapally Madhu Pavan (7):
qemu: Store inactive domain configuration in snapshot
qemu: Use active and inactive snapshot configuration on restore
conf: Allow editing inactive snapshot configuration
virsh: Dump inactive XML configuration of snapshot using
snapshot-dumpxml
virsh: Edit inactive XML configuration of snapshot using snapshot-edit
virsh: Allow restoring snapshot with non-persistent configuration
tests: docs: Add schema and testcase for domainsnapshot
docs/schemas/domainsnapshot.rng | 19 +++++
include/libvirt/libvirt-domain-snapshot.h | 10 ++-
include/libvirt/libvirt-domain.h | 1 +
src/conf/domain_conf.c | 6 +-
src/conf/domain_conf.h | 2 +
src/conf/snapshot_conf.c | 48 ++++++++++++-
src/conf/snapshot_conf.h | 1 +
src/qemu/qemu_driver.c | 33 ++++++++-
.../full_domain_withinactive.xml | 83 ++++++++++++++++++++++
tests/domainsnapshotxml2xmltest.c | 1 +
tools/virsh-snapshot.c | 20 ++++++
tools/virsh.pod | 37 +++++++++-
12 files changed, 251 insertions(+), 10 deletions(-)
create mode 100644 tests/domainsnapshotxml2xmlout/full_domain_withinactive.xml
--
1.8.3.1
6 years, 9 months
[libvirt] [PATCH 0/2] Add {lockd|logd} admin sockets to install
by John Ferlan
Hopefully I covered what's necessary... Essentially a bunch of
copying of existing examples...
I haven't been able to actually build an RPM locally for a long
time, but this does work with make install at least (or at least
it worked in the environment I tried it on).
John Ferlan (2):
logd: Install the admin sockets
lockd: Install the admin sockets
libvirt.spec.in | 20 ++++++++++++++++----
src/Makefile.am | 39 +++++++++++++++++++++++++++++++--------
2 files changed, 47 insertions(+), 12 deletions(-)
--
2.13.6
6 years, 9 months
[libvirt] [jenkins-ci PATCH v2 0/4] Fix virt-manager build failure
by Andrea Bolognani
Changes from [v1]:
* expand coverage instead of reducing it, which makes for a far
more acceptable solution.
[v1] https://www.redhat.com/archives/libvir-list/2018-February/msg00354.html
Andrea Bolognani (4):
jobs: Make Python version configurable
projects: Build libvirt-python for Python 3 too
projects: Build virt-manager using Python 3
guests: Fix Python installation
guests/host_vars/libvirt-centos-7/main.yml | 1 -
guests/host_vars/libvirt-debian-8/main.yml | 1 -
guests/host_vars/libvirt-ubuntu-14/main.yml | 1 -
guests/host_vars/libvirt-ubuntu-16/main.yml | 1 -
guests/vars/mappings.yml | 50 +++++++++++++++++------------
guests/vars/projects/libvirt-python.yml | 2 ++
guests/vars/projects/virt-manager.yml | 8 ++---
jobs/python-distutils.yaml | 22 ++++++-------
projects/libvirt-python.yaml | 29 +++++++++++++++--
projects/virt-manager.yaml | 14 ++++----
10 files changed, 80 insertions(+), 49 deletions(-)
--
2.14.3
6 years, 9 months
[libvirt] [PATCH python 1/1] Fix type extracting from PyDict
by Edgar Kaziakhmedov
PyInt_Check returns value whether or not an input object is the integer
type. The existing implementation of extracting leads to the wrong
type interpretation in the following code:
params = {libvirt.VIR_MIGRATE_PARAM_DISKS_PORT : 50123}
...
dom.migrate3(%option1, params, %option3)
where libvirt reports:
libvirt.libvirtError: invalid argument: invalid type 'ullong' for
parameter 'disks_port', expected 'int'
So, this patch fixes that bug and allows casting to the VIR_TYPED_PARAM_INT
type.
Signed-off-by: Edgar Kaziakhmedov <edgar.kaziakhmedov(a)virtuozzo.com>
---
libvirt-utils.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/libvirt-utils.c b/libvirt-utils.c
index f7b4478..3a00e9f 100644
--- a/libvirt-utils.c
+++ b/libvirt-utils.c
@@ -434,10 +434,7 @@ virPyDictToTypedParamOne(virTypedParameterPtr *params,
type = VIR_TYPED_PARAM_ULLONG;
#if PY_MAJOR_VERSION < 3
} else if (PyInt_Check(value)) {
- if (PyInt_AS_LONG(value) < 0)
- type = VIR_TYPED_PARAM_LLONG;
- else
- type = VIR_TYPED_PARAM_ULLONG;
+ type = VIR_TYPED_PARAM_INT;
#endif
} else if (PyFloat_Check(value)) {
type = VIR_TYPED_PARAM_DOUBLE;
--
2.11.0
6 years, 9 months
[libvirt] [PATCH] apparmor: allow libvirt to send term signal to unconfined
by Guido Günther
Otherwise stopping domains with qemu://session fails like
[164012.338157] audit: type=1400 audit(1516202208.784:99): apparmor="DENIED" operation="signal" profile="/usr/sbin/libvirtd" pid=18835 comm="libvirtd" requested_mask="send" denied_mask="send" signal=term peer="unconfined"
---
examples/apparmor/usr.sbin.libvirtd | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/examples/apparmor/usr.sbin.libvirtd b/examples/apparmor/usr.sbin.libvirtd
index 0ddec3f6e2..be4fabf905 100644
--- a/examples/apparmor/usr.sbin.libvirtd
+++ b/examples/apparmor/usr.sbin.libvirtd
@@ -63,7 +63,7 @@
signal (send) peer=/usr/sbin/dnsmasq,
signal (read, send) peer=libvirt-*,
- signal (send) set=("kill") peer=unconfined,
+ signal (send) set=("kill", "term") peer=unconfined,
# Very lenient profile for libvirtd since we want to first focus on confining
# the guests. Guests will have a very restricted profile.
--
2.15.1
6 years, 9 months
[libvirt] [PATCH v1 01/51] util: conf: separate virDomainDefParseXML into serial parts
by xinhua.Cao
beacause virDomainDefParseXML is too long, and all domain xml
parse in this function, it's difficulty to maintain this function
so separate virDomainDefParseXML into serial parts use
virDomainPreaseInfoFunc. then it will easy to maintain
---
src/conf/domain_conf.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 52 insertions(+)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 34aae82..e36783b 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -18527,6 +18527,28 @@ virDomainCachetuneDefParse(virDomainDefPtr def,
}
+typedef struct _virDomainParseTotalParam virDomainParseTotalParam;
+typedef virDomainParseTotalParam *virDomainParseTotalParamPtr;
+
+struct _virDomainParseTotalParam{
+ //input parameters
+ virDomainDefPtr def;
+ xmlDocPtr xml;
+ xmlNodePtr root;
+ xmlXPathContextPtr ctxt;
+ virCapsPtr caps;
+ virDomainXMLOptionPtr xmlopt;
+ void *parseOpaque;
+ unsigned int flags;
+
+ //internal parameters
+ bool usb_none;
+ bool usb_other;
+ bool usb_master;
+ bool uuid_generated;
+};
+
+
static virDomainDefPtr
virDomainDefParseXML(xmlDocPtr xml,
xmlNodePtr root,
@@ -18536,11 +18558,14 @@ virDomainDefParseXML(xmlDocPtr xml,
void *parseOpaque,
unsigned int flags)
{
+ typedef int (*virDomainPreaseInfoFunc)(virDomainParseTotalParamPtr params);
+
xmlNodePtr *nodes = NULL, node = NULL;
char *tmp = NULL;
size_t i, j;
int n, virtType, gic_version;
long id = -1;
+ size_t fun_index = 0;
virDomainDefPtr def;
bool uuid_generated = false;
virHashTablePtr bootHash = NULL;
@@ -18548,6 +18573,25 @@ virDomainDefParseXML(xmlDocPtr xml,
bool usb_other = false;
bool usb_master = false;
char *netprefix = NULL;
+ virDomainParseTotalParam param = {
+ NULL,
+ xml,
+ root,
+ ctxt,
+ caps,
+ xmlopt,
+ parseOpaque,
+ flags,
+ false,
+ false,
+ false,
+ false
+
+ };
+
+ virDomainPreaseInfoFunc parse_funs[] = {
+ NULL
+ };
if (flags & VIR_DOMAIN_DEF_PARSE_VALIDATE_SCHEMA) {
char *schema = virFileFindResource("domain.rng",
@@ -18565,6 +18609,14 @@ virDomainDefParseXML(xmlDocPtr xml,
if (!(def = virDomainDefNew()))
return NULL;
+ param.def = def;
+
+ while (parse_funs[fun_index]) {
+ if (parse_funs[fun_index](¶m) < 0)
+ goto error;
+ fun_index++;
+ }
+
if (!(flags & VIR_DOMAIN_DEF_PARSE_INACTIVE))
if (virXPathLong("string(./@id)", ctxt, &id) < 0)
id = -1;
--
2.8.3
6 years, 9 months
[libvirt] [PATCH v1 01/35] util: conf: add bootHash to virDomainParseTotalParam
by xinhua.Cao
add bootHash to virDomainParseTotalParam
---
src/conf/domain_conf.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 1e949ea..1a8248d 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -18516,6 +18516,7 @@ struct _virDomainParseTotalParam{
virCapsPtr caps;
virDomainXMLOptionPtr xmlopt;
void *parseOpaque;
+ virHashTablePtr bootHash;
unsigned int flags;
//internal parameters
@@ -19816,6 +19817,7 @@ virDomainDefParseXML(xmlDocPtr xml,
caps,
xmlopt,
parseOpaque,
+ NULL,
flags,
false,
false,
@@ -19861,7 +19863,11 @@ virDomainDefParseXML(xmlDocPtr xml,
if (!(def = virDomainDefNew()))
return NULL;
+ if (!(bootHash = virHashCreate(5, NULL)))
+ goto error;
+
param.def = def;
+ param.bootHash = bootHash;
while (parse_funs[fun_index]) {
if (parse_funs[fun_index](¶m) < 0)
--
2.8.3
6 years, 9 months