[libvirt] [PATCH v3] lxc: fix show the wrong xml when guest start failed
by Luyao Huang
https://bugzilla.redhat.com/show_bug.cgi?id=1176503
When guest start failed, libvirt will keep the current vm->def,
this will make a issue that we cannot get a right xml after guest
start failed. And don't call the stop/release hook to do some
other clean work.
Call virLXCProcessCleanup to help us clean the source and call
the hooks if start a vm failed
Signed-off-by: Luyao Huang <lhuang(a)redhat.com>
---
v2: use virLXCProcessCleanup to free the source and call the hook.
v3: rework the patch to suit the virLXCProcessStart code changed.
src/lxc/lxc_process.c | 76 ++++++++++++++++++++++-----------------------------
1 file changed, 32 insertions(+), 44 deletions(-)
diff --git a/src/lxc/lxc_process.c b/src/lxc/lxc_process.c
index 01da344..1a6cfbb 100644
--- a/src/lxc/lxc_process.c
+++ b/src/lxc/lxc_process.c
@@ -1022,6 +1022,7 @@ int virLXCProcessStart(virConnectPtr conn,
virCgroupPtr selfcgroup;
int status;
char *pidfile = NULL;
+ bool need_stop = false;
if (virCgroupNewSelf(&selfcgroup) < 0)
return -1;
@@ -1259,6 +1260,7 @@ int virLXCProcessStart(virConnectPtr conn,
goto cleanup;
}
+ need_stop = true;
priv->stopReason = VIR_DOMAIN_EVENT_STOPPED_FAILED;
priv->wantReboot = false;
vm->def->id = vm->pid;
@@ -1272,20 +1274,20 @@ int virLXCProcessStart(virConnectPtr conn,
if (VIR_CLOSE(handshakefds[1]) < 0) {
virReportSystemError(errno, "%s", _("could not close handshake fd"));
- goto error;
+ goto cleanup;
}
if (virCommandHandshakeWait(cmd) < 0)
- goto error;
+ goto cleanup;
/* Write domain status to disk for the controller to
* read when it starts */
if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm) < 0)
- goto error;
+ goto cleanup;
/* Allow the child to exec the controller */
if (virCommandHandshakeNotify(cmd) < 0)
- goto error;
+ goto cleanup;
if (virAtomicIntInc(&driver->nactive) == 1 && driver->inhibitCallback)
driver->inhibitCallback(true, driver->inhibitOpaque);
@@ -1298,7 +1300,7 @@ int virLXCProcessStart(virConnectPtr conn,
_("guest failed to start: %s"), out);
}
- goto error;
+ goto cleanup;
}
/* We know the cgroup must exist by this synchronization
@@ -1310,13 +1312,13 @@ int virLXCProcessStart(virConnectPtr conn,
vm->def->resource->partition :
NULL,
-1, &priv->cgroup) < 0)
- goto error;
+ goto cleanup;
if (!priv->cgroup) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("No valid cgroup for machine %s"),
vm->def->name);
- goto error;
+ goto cleanup;
}
/* And we can get the first monitor connection now too */
@@ -1329,17 +1331,17 @@ int virLXCProcessStart(virConnectPtr conn,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("guest failed to start: %s"), ebuf);
}
- goto error;
+ goto cleanup;
}
if (autoDestroy &&
virCloseCallbacksSet(driver->closeCallbacks, vm,
conn, lxcProcessAutoDestroy) < 0)
- goto error;
+ goto cleanup;
if (virDomainObjSetDefTransient(caps, driver->xmlopt,
vm, false) < 0)
- goto error;
+ goto cleanup;
/* We don't need the temporary NIC names anymore, clear them */
virLXCProcessCleanInterfaces(vm->def);
@@ -1358,47 +1360,38 @@ int virLXCProcessStart(virConnectPtr conn,
* If the script raised an error abort the launch
*/
if (hookret < 0)
- goto error;
+ goto cleanup;
}
rc = 0;
cleanup:
- if (rc != 0 && !err)
- err = virSaveLastError();
- virCommandFree(cmd);
if (VIR_CLOSE(logfd) < 0) {
virReportSystemError(errno, "%s", _("could not close logfile"));
rc = -1;
}
- for (i = 0; i < nveths; i++) {
- if (rc != 0 && veths[i])
- ignore_value(virNetDevVethDelete(veths[i]));
- VIR_FREE(veths[i]);
- }
if (rc != 0) {
- if (vm->newDef) {
- virDomainDefFree(vm->newDef);
- vm->newDef = NULL;
- }
- if (priv->monitor) {
- virObjectUnref(priv->monitor);
- priv->monitor = NULL;
- }
- virDomainConfVMNWFilterTeardown(vm);
-
- virSecurityManagerRestoreAllLabel(driver->securityManager,
- vm->def, false);
- virSecurityManagerReleaseLabel(driver->securityManager, vm->def);
- /* Clear out dynamically assigned labels */
- if (vm->def->nseclabels &&
- vm->def->seclabels[0]->type == VIR_DOMAIN_SECLABEL_DYNAMIC) {
- VIR_FREE(vm->def->seclabels[0]->model);
- VIR_FREE(vm->def->seclabels[0]->label);
- VIR_FREE(vm->def->seclabels[0]->imagelabel);
- VIR_DELETE_ELEMENT(vm->def->seclabels, 0, vm->def->nseclabels);
+ err = virSaveLastError();
+ if (need_stop) {
+ virLXCProcessStop(driver, vm, VIR_DOMAIN_SHUTOFF_FAILED);
+ } else {
+ virSecurityManagerRestoreAllLabel(driver->securityManager,
+ vm->def, false);
+ virSecurityManagerReleaseLabel(driver->securityManager, vm->def);
+ /* Clear out dynamically assigned labels */
+ if (vm->def->nseclabels &&
+ vm->def->seclabels[0]->type == VIR_DOMAIN_SECLABEL_DYNAMIC) {
+ VIR_FREE(vm->def->seclabels[0]->model);
+ VIR_FREE(vm->def->seclabels[0]->label);
+ VIR_FREE(vm->def->seclabels[0]->imagelabel);
+ VIR_DELETE_ELEMENT(vm->def->seclabels, 0, vm->def->nseclabels);
+ }
+ virLXCProcessCleanup(driver, vm, VIR_DOMAIN_SHUTOFF_FAILED);
}
}
+ virCommandFree(cmd);
+ for (i = 0; i < nveths; i++)
+ VIR_FREE(veths[i]);
for (i = 0; i < nttyFDs; i++)
VIR_FORCE_CLOSE(ttyFDs[i]);
VIR_FREE(ttyFDs);
@@ -1415,11 +1408,6 @@ int virLXCProcessStart(virConnectPtr conn,
}
return rc;
-
- error:
- err = virSaveLastError();
- virLXCProcessStop(driver, vm, VIR_DOMAIN_SHUTOFF_FAILED);
- goto cleanup;
}
struct virLXCProcessAutostartData {
--
1.8.3.1
10 years, 2 months
[libvirt] [PATCH 0/2] Support mrg_rxbuf attribute for virtio-net devices
by Ján Tomko
For https://bugzilla.redhat.com/show_bug.cgi?id=1186886
Ján Tomko (2):
Add mrg_rxbuf option to virtio interfaces
Wire up mrg_rxbuf option for qemu
docs/formatdomain.html.in | 6 +++++-
docs/schemas/domaincommon.rng | 5 +++++
src/conf/domain_conf.c | 14 ++++++++++++++
src/conf/domain_conf.h | 1 +
src/qemu/qemu_command.c | 4 ++++
src/qemu/qemu_hotplug.c | 1 +
.../qemuxml2argv-net-virtio-disable-offloads.args | 2 +-
.../qemuxml2argv-net-virtio-disable-offloads.xml | 2 +-
8 files changed, 32 insertions(+), 3 deletions(-)
--
2.0.5
10 years, 2 months
[libvirt] [PATCH 0/5 v2] parallels: Better bridged network interfaces support and some fixes
by Maxim Nestratov
v2 changes:
- syntax check fixed
- patches reordered and split
- dealing with failed bridged network information fixed
Maxim Nestratov (4):
parallels: don't forget to unlock domain if unregister fails
parallels: better bridge network interface support
parallels: fix home directory for VMs
parallels: fix initialization of parallels driver
Mikhail Feoktistov (1):
parallels: set cpu mode when applying xml configuration
10 years, 2 months
[libvirt] [PATCH] virprocess: fix MinGW build and RHEL-5 build
by Pavel Hrdina
Commit b6a2828e introduced new functions to set process scheduler. There
is a small typo in ELSE path for systems where scheduler is not
available.
Also some of the definitions were introduced later in kernel. For
example RHEL-5 is running on kernel 2.6.18, but SCHED_IDLE was introduces
in 2.6.23 [1] and SCHED_BATCH in 2.6.16 [1]. We should not count only on
existence of function sched_setscheduler(), we must also check for
existence of used macros as they might not be defined.
[1] see 'man 7 sched'
Signed-off-by: Pavel Hrdina <phrdina(a)redhat.com>
---
src/util/virprocess.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/src/util/virprocess.c b/src/util/virprocess.c
index b3e5435..342bf40 100644
--- a/src/util/virprocess.c
+++ b/src/util/virprocess.c
@@ -1062,7 +1062,7 @@ virProcessExitWithStatus(int status)
exit(value);
}
-#if HAVE_SCHED_SETSCHEDULER
+#if HAVE_SCHED_SETSCHEDULER && defined(SCHED_BATCH) && defined(SCHED_IDLE)
static int
virProcessSchedTranslatePolicy(virProcessSchedPolicy policy)
@@ -1092,7 +1092,9 @@ virProcessSchedTranslatePolicy(virProcessSchedPolicy policy)
}
int
-virProcessSetScheduler(pid_t pid, virProcessSchedPolicy policy, int priority)
+virProcessSetScheduler(pid_t pid,
+ virProcessSchedPolicy policy,
+ int priority)
{
struct sched_param param = {0};
int pol = virProcessSchedTranslatePolicy(policy);
@@ -1144,7 +1146,7 @@ virProcessSetScheduler(pid_t pid, virProcessSchedPolicy policy, int priority)
int
virProcessSetScheduler(pid_t pid ATTRIBUTE_UNUSED,
- int policy,
+ virProcessSchedPolicy policy,
int priority ATTRIBUTE_UNUSED)
{
if (!policy)
--
2.0.5
10 years, 2 months
[libvirt] [PATCH] Fix a syntax error in the description text of libvirtd.conf
by Zhang Bo
not yet not -> not yet.
Signed-off-by: Zhang Bo <oscar.zhangbo(a)huawei.com>
---
daemon/libvirtd.conf | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/daemon/libvirtd.conf b/daemon/libvirtd.conf
index d4f6a1c..069ef3a 100644
--- a/daemon/libvirtd.conf
+++ b/daemon/libvirtd.conf
@@ -272,7 +272,7 @@
# connection succeeds.
#max_queued_clients = 1000
-# The maximum length of queue of accepted but not yet not
+# The maximum length of queue of accepted but not yet
# authenticated clients. The default value is zero, meaning
# the feature is disabled.
#max_anonymous_clients = 20
--
1.7.12.4
10 years, 2 months
[libvirt] [PATCHv2] libxl: set IP address when creating NIC
by Jihoon Kim
From: Ji-hoon Kim <relip(a)me.com>
Currently libxlMakeNic() does not set ip address when creating NIC,
this patch makes it to set ip address.
Signed-off-by: Ji-hoon Kim <relip(a)me.com>
---
src/libxl/libxl_conf.c | 14 ++++++++++++++
1 files changed, 14 insertions(+), 0 deletions(-)
diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c
index 0555b91..e49715d 100644
--- a/src/libxl/libxl_conf.c
+++ b/src/libxl/libxl_conf.c
@@ -1042,6 +1042,20 @@ libxlMakeNic(virDomainDefPtr def,
if (VIR_STRDUP(x_nic->ifname, l_nic->ifname) < 0)
return -1;
+ if (l_nic->nips == 1) {
+ char *ipStr = virSocketAddrFormat(&l_nic->ips[0]->address);
+ if (VIR_STRDUP(x_nic->ip, ipStr) < 0) {
+ VIR_FREE(ipStr);
+ return -1;
+ }
+ VIR_FREE(ipStr);
+ }
+ else if (l_nic->nips > 1) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("Driver does not support setting multiple IP addresses"));
+ return -1;
+ }
+
switch (actual_type) {
case VIR_DOMAIN_NET_TYPE_BRIDGE:
if (VIR_STRDUP(x_nic->bridge,
--
1.7.1
10 years, 2 months
[libvirt] [PATCH] util: make use of VIR_LOCK_SPACE_ACQUIRE_AUTOCREATE in virLockSpaceAcquireResource
by Shanzhi Yu
When create external disk snapshot with virtlock enabled, libvirtd
will hang if flag VIR_LOCK_SPACE_ACQUIRE_AUTOCREATE is missed in
virLockSpaceAcquireResource.
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1191901
Signed-off-by: Shanzhi Yu <shyu(a)redhat.com>
---
src/util/virlockspace.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/src/util/virlockspace.c b/src/util/virlockspace.c
index 2366a74..25b4433 100644
--- a/src/util/virlockspace.c
+++ b/src/util/virlockspace.c
@@ -626,8 +626,10 @@ int virLockSpaceAcquireResource(virLockSpacePtr lockspace,
virMutexLock(&lockspace->lock);
if ((res = virHashLookup(lockspace->resources, resname))) {
- if ((res->flags & VIR_LOCK_SPACE_ACQUIRE_SHARED) &&
- (flags & VIR_LOCK_SPACE_ACQUIRE_SHARED)) {
+ if (((res->flags & VIR_LOCK_SPACE_ACQUIRE_SHARED) &&
+ (flags & VIR_LOCK_SPACE_ACQUIRE_SHARED)) ||
+ ((res->flags & VIR_LOCK_SPACE_ACQUIRE_AUTOCREATE) &&
+ (flags & VIR_LOCK_SPACE_ACQUIRE_AUTOCREATE))){
if (VIR_EXPAND_N(res->owners, res->nOwners, 1) < 0)
goto cleanup;
--
1.8.3.1
10 years, 2 months
[libvirt] [PATCH 0/4] Introduce display of IOThreads Information
by John Ferlan
These patches satisfy part of:
https://bugzilla.redhat.com/show_bug.cgi?id=1135491
Patches 1 and 2 are fairly straightforward adding a new API type patches
although they were implemented with the thought of how patch 3 works. Also
rather than implement a get iothreads and a get iothreadspin API, I combined
the two into one. I could separate if that's more desirable, but it just
seemed more natural to have one API do both.
Patch 3 adds the qemu related to code to fetch not only the IOThreads
data, but also the cpumap/cpumaplen in order to display the CPU Affinity.
For that I somewhat followed how the vcpuinfo code works, but also a bit
on how the nodecpumap code does things. Unlike the vcpuinfo code, I had
no way to count the IOThreads before calling, so rather than pass in a
cpumap/cpumaplen - I allocated them in the qemu code and passed them back
within the IOThreadsInfo structure. Of course it did get me to thinking
why are we doing 1 for each IOThread, but to that degree I was following
the vcpu model.
Patch 4 is the new 'virsh iothreads' command with no arguments (for now).
It will display the IOThreads of active domains only.
"Future" patches will implement a SetIOThreads API to change the
thread pinning and allow for add/delete of IOThreads. I'm hoping to
use the same command with new options --pin && --cpuset for pinning
the IOThreads or --add/--del to add/remove IOThreads, but I wanted to
make sure I had buyin on the use of one API to accomplish both get of
basic IOThread data and CPU Affinity data.
John Ferlan (4):
Implement public API for virDomainGetIOThreadsInfo
remote: Implement the remote plumbing for virDomainGetIOThreads
qemu: Implement the qemu driver fetch for IOThreads
virsh: Add 'iothreads' command
daemon/remote.c | 75 +++++++++++++++++++++++++-
include/libvirt/libvirt-domain.h | 22 +++++++-
src/driver-hypervisor.h | 8 ++-
src/libvirt-domain.c | 63 +++++++++++++++++++++-
src/libvirt_public.syms | 6 +++
src/qemu/qemu_driver.c | 114 +++++++++++++++++++++++++++++++++++++++
src/remote/remote_driver.c | 82 +++++++++++++++++++++++++++-
src/remote/remote_protocol.x | 29 +++++++++-
src/remote_protocol-structs | 20 +++++++
src/rpc/gendispatch.pl | 1 +
tools/virsh-domain.c | 72 +++++++++++++++++++++++++
tools/virsh.pod | 7 +++
12 files changed, 492 insertions(+), 7 deletions(-)
--
2.1.0
10 years, 2 months
[libvirt] [PATCH v2 0/4] security: Add check for invalid security models and duplicates
by Erik Skultety
Erik Skultety (4):
security: Refactor virSecurityManagerGenLabel
security: introduce virSecurityManagerCheckAllLabel function
conf: forbid seclabel duplicates for domain devices
schema: allow multiple seclabel for devices in domaincommon.rng
docs/schemas/domaincommon.rng | 16 +--
src/conf/domain_conf.c | 9 ++
src/libvirt_private.syms | 1 +
src/qemu/qemu_process.c | 6 +
src/security/security_manager.c | 146 ++++++++++++++++++---
src/security/security_manager.h | 2 +
.../qemuxml2argv-seclabel-device-duplicates.xml | 33 +++++
.../qemuxml2argv-seclabel-device-multiple.xml | 32 +++++
tests/qemuxml2argvtest.c | 1 +
tests/qemuxml2xmltest.c | 1 +
10 files changed, 220 insertions(+), 27 deletions(-)
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-seclabel-device-duplicates.xml
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-seclabel-device-multiple.xml
--
1.9.3
10 years, 2 months
[libvirt] [PATCH v2 0/3] Add support for vCPU and I/O thread scheduler setting
by Martin Kletzander
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1178986
v2:
- No dependency on sched.h unless really needed
- Docs fixed according to John
- RNG schema matches parsing
- Possibility to specify one element for whole mask of vcpus/iothreads
- leaks fixed (VIR_FREE(nodes);) O:-)
- not accepting "other" as a scheduler when parsing
- Rebased, of course
Martin Kletzander (3):
util: Add virProcessSetScheduler() function for scheduler settings
docs, schema, conf: Add support for setting scheduler parameters of
guest threads
qemu: Add support for setting vCPU and I/O thread scheduler setting
configure.ac | 4 +-
docs/formatdomain.html.in | 16 ++
docs/schemas/domaincommon.rng | 44 +++++
src/conf/domain_conf.c | 183 ++++++++++++++++++++-
src/conf/domain_conf.h | 24 +++
src/libvirt_private.syms | 1 +
src/qemu/qemu_driver.c | 5 +
src/qemu/qemu_process.c | 57 ++++++-
src/qemu/qemu_process.h | 5 +-
src/util/virprocess.c | 104 +++++++++++-
src/util/virprocess.h | 20 ++-
.../qemuxml2argv-cputune-iothreadsched-toomuch.xml | 38 +++++
.../qemuxml2argv-cputune-iothreadsched.xml | 39 +++++
.../qemuxml2argv-cputune-vcpusched-overlap.xml | 38 +++++
tests/qemuxml2argvtest.c | 2 +
.../qemuxml2xmlout-cputune-iothreadsched.xml | 39 +++++
tests/qemuxml2xmltest.c | 1 +
17 files changed, 612 insertions(+), 8 deletions(-)
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-cputune-iothreadsched-toomuch.xml
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-cputune-iothreadsched.xml
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-cputune-vcpusched-overlap.xml
create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-cputune-iothreadsched.xml
--
2.3.0
10 years, 2 months