[libvirt] [PATCH] spec: Automatically turn on cgconfig service
by Jiri Denemark
From: Daniel P. Berrange <berrange(a)redhat.com>
A number of the libvirt APIs require the use of cgroups. This is not
enabled by default on a RHEL6 install. After discussion with cgroups
team, it was decided that upon installation of the libvirt RPM, we
should automatically turn on the cgroups service. This will activate a
default configuration that turns on all cgroups controllers libvirt
requires for full operation.
---
libvirt.spec.in | 17 +++++++++++++++++
1 files changed, 17 insertions(+), 0 deletions(-)
diff --git a/libvirt.spec.in b/libvirt.spec.in
index 7c60eba..5ea3422 100644
--- a/libvirt.spec.in
+++ b/libvirt.spec.in
@@ -68,6 +68,7 @@
%define with_libnl 0%{!?_without_libnl:0}
%define with_audit 0%{!?_without_audit:0}
%define with_dtrace 0%{!?_without_dtrace:0}
+%define with_cgconfig 0%{!?_without_cgconfig:0}
# Non-server/HV driver defaults which are always enabled
%define with_python 0%{!?_without_python:1}
@@ -169,6 +170,13 @@
%define with_dtrace 1
%endif
+# Pull in cgroups config system
+%if 0%{?fedora} >= 12 || 0%{?rhel} >= 6
+%if %{with_qemu} || %{with_lxc}
+%define with_cgconfig 0%{!?_without_cgconfig:1}
+%endif
+%endif
+
# Force QEMU to run as non-root
%if 0%{?fedora} >= 12 || 0%{?rhel} >= 6
%define qemu_user qemu
@@ -271,6 +279,9 @@ Requires: parted
# For multipath support
Requires: device-mapper
%endif
+%if %{with_cgconfig}
+Requires: libcgroup
+%endif
%if %{with_xen}
BuildRequires: xen-devel
%endif
@@ -725,6 +736,12 @@ then
fi
%endif
+%if %{with_cgconfig}
+if [ "$1" -eq "1" ]; then
+/sbin/chkconfig cgconfig on
+fi
+%endif
+
/sbin/chkconfig --add libvirtd
if [ "$1" -ge "1" ]; then
/sbin/service libvirtd condrestart > /dev/null 2>&1
--
1.7.3.4
14 years
[libvirt] [PATCH] spec: Enable ESX driver on RHEL
by Jiri Denemark
---
libvirt.spec.in | 3 +--
1 files changed, 1 insertions(+), 2 deletions(-)
diff --git a/libvirt.spec.in b/libvirt.spec.in
index 5ea3422..fd99a54 100644
--- a/libvirt.spec.in
+++ b/libvirt.spec.in
@@ -87,7 +87,7 @@
%define with_numactl 0
%endif
-# RHEL doesn't ship OpenVZ, VBox, UML, OpenNebula, PowerHypervisor, ESX,
+# RHEL doesn't ship OpenVZ, VBox, UML, OpenNebula, PowerHypervisor,
# VMWare, or libxenserver (xenapi)
%if 0%{?rhel}
%define with_openvz 0
@@ -95,7 +95,6 @@
%define with_uml 0
%define with_one 0
%define with_phyp 0
-%define with_esx 0
%define with_vmware 0
%define with_xenapi 0
%endif
--
1.7.3.4
14 years
[libvirt] [PATCH] initgroups() in qemudOpenAsUID()
by Dan Kenigsberg
qemudOpenAsUID is intended to open a file with the credentials of a
specified uid. Current implementation fails if the file is accessible to
one of uid's groups but not owned by uid.
This patch replaces the supplementary group list that the child process
inherited from libvirtd with the default group list of uid.
---
src/qemu/qemu_driver.c | 16 ++++++++++++++++
1 files changed, 16 insertions(+), 0 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 0ce2d40..a1027d4 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -6353,6 +6353,7 @@ parent_cleanup:
char *buf = NULL;
size_t bufsize = 1024 * 1024;
int bytesread;
+ struct passwd *pwd;
/* child doesn't need the read side of the pipe */
close(pipefd[0]);
@@ -6365,6 +6366,21 @@ parent_cleanup:
goto child_cleanup;
}
+ /* we can avoid getpwuid_r() in threadless child */
+ if ((pwd = getpwuid(uid)) == NULL) {
+ exit_code = errno;
+ virReportSystemError(errno,
+ _("cannot setuid(%d) to read '%s'"),
+ uid, path);
+ goto child_cleanup;
+ }
+ if (initgroups(pwd->pw_name, pwd->pw_gid) != 0) {
+ exit_code = errno;
+ virReportSystemError(errno,
+ _("cannot setuid(%d) to read '%s'"),
+ uid, path);
+ goto child_cleanup;
+ }
if (setuid(uid) != 0) {
exit_code = errno;
virReportSystemError(errno,
--
1.7.2.3
14 years
[libvirt] [PATCH] spec: Really skip tests that don't work in mock build root
by Jiri Denemark
Two of the tests we want to skip are C tests and since we moved
compiling tests to make check phase, replacing compiled binary with a
no-op shell script before running make check doesn't really work for
them. We need to replace the source of such tests.
---
libvirt.spec.in | 8 ++++++--
1 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/libvirt.spec.in b/libvirt.spec.in
index fd99a54..3889f5d 100644
--- a/libvirt.spec.in
+++ b/libvirt.spec.in
@@ -700,8 +700,12 @@ cd tests
for i in nodeinfotest daemon-conf seclabeltest
do
rm -f $i
- printf "#!/bin/sh\nexit 0\n" > $i
- chmod +x $i
+ if [ -f $i.c ]; then
+ echo 'int main(void) { return 0; }' > $i.c
+ else
+ printf "#!/bin/sh\nexit 0\n" > $i
+ chmod +x $i
+ fi
done
make check
--
1.7.3.4
14 years
[libvirt] [PATCH] docs: Make VMware Workstation / Player page appear in the menu
by Matthias Bolte
By adding it to sitemap.html.in. Also <ul> can't be nested in <p>.
---
docs/drvvmware.html.in | 4 +++-
docs/sitemap.html.in | 4 ++++
2 files changed, 7 insertions(+), 1 deletions(-)
diff --git a/docs/drvvmware.html.in b/docs/drvvmware.html.in
index 273e0a0..0ef6044 100644
--- a/docs/drvvmware.html.in
+++ b/docs/drvvmware.html.in
@@ -1,6 +1,6 @@
<html>
<body>
- <h1>VMware Workstation/Player hypervisors driver</h1>
+ <h1>VMware Workstation / Player hypervisors driver</h1>
<p>
The libvirt VMware Workstation driver should be able to manage any Workstation and
Player version supported by the VMware VIX API. See the compatibility list
@@ -15,10 +15,12 @@
<p>
The libvirt VMware driver provides per-user drivers (the "session" instance).
Two uris are available:
+ </p>
<ul>
<li>"vmwareplayer" for VMware Player</li>
<li>"vmwarews" for VMware Workstation</li>
</ul>
+ <p>
Some example connection URIs for the driver are:
</p>
diff --git a/docs/sitemap.html.in b/docs/sitemap.html.in
index 63e420f..490450e 100644
--- a/docs/sitemap.html.in
+++ b/docs/sitemap.html.in
@@ -192,6 +192,10 @@
<a href="drvesx.html">VMware ESX</a>
<span>Driver for VMware ESX</span>
</li>
+ <li>
+ <a href="drvvmware.html">VMware Workstation / Player</a>
+ <span>Driver for VMware Workstation / Player</span>
+ </li>
</ul>
</li>
<li>
--
1.7.0.4
14 years
[libvirt] [PATCH] qemu: Reparent children when deleting a snapshot
by Matthias Bolte
Shorten qemuDomainSnapshotWriteSnapshotMetadata function name
and make it take a snapshot pointer instead of dealing with
the current snapshot. Update other functions accordingly.
Add a qemuDomainSnapshotReparentChildren hash iterator to
reparent the children of a snapshot that is being deleted. Use
qemuDomainSnapshotWriteMetadata to write updated metadata
to disk.
This fixes a problem where outdated parent information breaks
the snapshot tree and hinders the deletion of child snapshots.
Reported by Philipp Hahn.
---
src/qemu/qemu_driver.c | 92 +++++++++++++++++++++++++++++++++++++-----------
1 files changed, 71 insertions(+), 21 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 924446f..9b538a3 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -2607,10 +2607,10 @@ qemuPrepareMonitorChr(struct qemud_driver *driver,
return 0;
}
-static int qemuDomainSnapshotSetActive(virDomainObjPtr vm,
- char *snapshotDir);
-static int qemuDomainSnapshotSetInactive(virDomainObjPtr vm,
- char *snapshotDir);
+static int qemuDomainSnapshotSetCurrentActive(virDomainObjPtr vm,
+ char *snapshotDir);
+static int qemuDomainSnapshotSetCurrentInactive(virDomainObjPtr vm,
+ char *snapshotDir);
#define START_POSTFIX ": starting up\n"
@@ -2807,7 +2807,7 @@ static int qemudStartVMDaemon(virConnectPtr conn,
vm->current_snapshot, vmop)))
goto cleanup;
- if (qemuDomainSnapshotSetInactive(vm, driver->snapshotDir) < 0)
+ if (qemuDomainSnapshotSetCurrentInactive(vm, driver->snapshotDir) < 0)
goto cleanup;
/* now that we know it is about to start call the hook if present */
@@ -9472,8 +9472,9 @@ static char *qemuFindQemuImgBinary(void)
return ret;
}
-static int qemuDomainSnapshotWriteSnapshotMetadata(virDomainObjPtr vm,
- char *snapshotDir)
+static int qemuDomainSnapshotWriteMetadata(virDomainObjPtr vm,
+ virDomainSnapshotObjPtr snapshot,
+ char *snapshotDir)
{
int fd = -1;
char *newxml = NULL;
@@ -9484,7 +9485,7 @@ static int qemuDomainSnapshotWriteSnapshotMetadata(virDomainObjPtr vm,
char uuidstr[VIR_UUID_STRING_BUFLEN];
virUUIDFormat(vm->def->uuid, uuidstr);
- newxml = virDomainSnapshotDefFormat(uuidstr, vm->current_snapshot->def, 1);
+ newxml = virDomainSnapshotDefFormat(uuidstr, snapshot->def, 1);
if (newxml == NULL) {
virReportOOMError();
return -1;
@@ -9501,8 +9502,7 @@ static int qemuDomainSnapshotWriteSnapshotMetadata(virDomainObjPtr vm,
goto cleanup;
}
- if (virAsprintf(&snapFile, "%s/%s.xml", snapDir,
- vm->current_snapshot->def->name) < 0) {
+ if (virAsprintf(&snapFile, "%s/%s.xml", snapDir, snapshot->def->name) < 0) {
virReportOOMError();
goto cleanup;
}
@@ -9528,25 +9528,27 @@ cleanup:
return ret;
}
-static int qemuDomainSnapshotSetActive(virDomainObjPtr vm,
- char *snapshotDir)
+static int qemuDomainSnapshotSetCurrentActive(virDomainObjPtr vm,
+ char *snapshotDir)
{
if (vm->current_snapshot) {
vm->current_snapshot->def->active = 1;
- return qemuDomainSnapshotWriteSnapshotMetadata(vm, snapshotDir);
+ return qemuDomainSnapshotWriteMetadata(vm, vm->current_snapshot,
+ snapshotDir);
}
return 0;
}
-static int qemuDomainSnapshotSetInactive(virDomainObjPtr vm,
- char *snapshotDir)
+static int qemuDomainSnapshotSetCurrentInactive(virDomainObjPtr vm,
+ char *snapshotDir)
{
if (vm->current_snapshot) {
vm->current_snapshot->def->active = 0;
- return qemuDomainSnapshotWriteSnapshotMetadata(vm, snapshotDir);
+ return qemuDomainSnapshotWriteMetadata(vm, vm->current_snapshot,
+ snapshotDir);
}
return 0;
@@ -9686,8 +9688,9 @@ static virDomainSnapshotPtr qemuDomainSnapshotCreateXML(virDomainPtr domain,
/* Now we set the new current_snapshot for the domain */
vm->current_snapshot = snap;
- if (qemuDomainSnapshotWriteSnapshotMetadata(vm, driver->snapshotDir) < 0)
- /* qemuDomainSnapshotWriteSnapshotMetadata set the error */
+ if (qemuDomainSnapshotWriteMetadata(vm, vm->current_snapshot,
+ driver->snapshotDir) < 0)
+ /* qemuDomainSnapshotWriteMetadata set the error */
goto cleanup;
snapshot = virGetDomainSnapshot(domain, snap->def->name);
@@ -9941,13 +9944,13 @@ static int qemuDomainRevertToSnapshot(virDomainSnapshotPtr snapshot,
goto endjob;
}
else {
- if (qemuDomainSnapshotSetActive(vm, driver->snapshotDir) < 0)
+ if (qemuDomainSnapshotSetCurrentActive(vm, driver->snapshotDir) < 0)
goto endjob;
rc = qemudStartVMDaemon(snapshot->domain->conn, driver, vm, NULL,
false, -1, NULL, VIR_VM_OP_CREATE);
qemuDomainStartAudit(vm, "from-snapshot", rc >= 0);
- if (qemuDomainSnapshotSetInactive(vm, driver->snapshotDir) < 0)
+ if (qemuDomainSnapshotSetCurrentInactive(vm, driver->snapshotDir) < 0)
goto endjob;
if (rc < 0)
goto endjob;
@@ -9991,7 +9994,7 @@ static int qemuDomainRevertToSnapshot(virDomainSnapshotPtr snapshot,
}
}
- if (qemuDomainSnapshotSetActive(vm, driver->snapshotDir) < 0)
+ if (qemuDomainSnapshotSetCurrentActive(vm, driver->snapshotDir) < 0)
goto endjob;
}
@@ -10128,6 +10131,43 @@ static void qemuDomainSnapshotDiscardChildren(void *payload,
}
}
+struct snap_reparent {
+ struct qemud_driver *driver;
+ virDomainSnapshotObjPtr snap;
+ virDomainObjPtr vm;
+ int err;
+};
+
+static void
+qemuDomainSnapshotReparentChildren(void *payload,
+ const char *name ATTRIBUTE_UNUSED,
+ void *data)
+{
+ virDomainSnapshotObjPtr snap = payload;
+ struct snap_reparent *rep = data;
+
+ if (rep->err < 0) {
+ return;
+ }
+
+ if (snap->def->parent && STREQ(snap->def->parent, rep->snap->def->name)) {
+ VIR_FREE(snap->def->parent);
+
+ if (rep->snap->def->parent != NULL) {
+ snap->def->parent = strdup(rep->snap->def->parent);
+
+ if (snap->def->parent == NULL) {
+ virReportOOMError();
+ rep->err = -1;
+ return;
+ }
+ }
+
+ rep->err = qemuDomainSnapshotWriteMetadata(rep->vm, snap,
+ rep->driver->snapshotDir);
+ }
+}
+
static int qemuDomainSnapshotDelete(virDomainSnapshotPtr snapshot,
unsigned int flags)
{
@@ -10137,6 +10177,7 @@ static int qemuDomainSnapshotDelete(virDomainSnapshotPtr snapshot,
virDomainSnapshotObjPtr snap = NULL;
char uuidstr[VIR_UUID_STRING_BUFLEN];
struct snap_remove rem;
+ struct snap_reparent rep;
virCheckFlags(VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN, -1);
@@ -10169,6 +10210,15 @@ static int qemuDomainSnapshotDelete(virDomainSnapshotPtr snapshot,
&rem);
if (rem.err < 0)
goto endjob;
+ } else {
+ rep.driver = driver;
+ rep.snap = snap;
+ rep.vm = vm;
+ rep.err = 0;
+ virHashForEach(vm->snapshots.objs, qemuDomainSnapshotReparentChildren,
+ &rep);
+ if (rep.err < 0)
+ goto endjob;
}
ret = qemuDomainSnapshotDiscard(driver, vm, snap);
--
1.7.0.4
14 years
[libvirt] [PATCH] virsh: Add --force option to update-device
by Jiri Denemark
---
tools/virsh.c | 5 +++++
tools/virsh.pod | 14 ++++++++------
2 files changed, 13 insertions(+), 6 deletions(-)
diff --git a/tools/virsh.c b/tools/virsh.c
index 4e37f2d..774d937 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -8293,6 +8293,7 @@ static const vshCmdOptDef opts_update_device[] = {
{"domain", VSH_OT_DATA, VSH_OFLAG_REQ, N_("domain name, id or uuid")},
{"file", VSH_OT_DATA, VSH_OFLAG_REQ, N_("XML file")},
{"persistent", VSH_OT_BOOL, 0, N_("persist device update")},
+ {"force", VSH_OT_BOOL, 0, N_("force device update")},
{NULL, 0, 0, NULL}
};
@@ -8331,6 +8332,10 @@ cmdUpdateDevice(vshControl *ctl, const vshCmd *cmd)
} else {
flags = VIR_DOMAIN_DEVICE_MODIFY_LIVE;
}
+
+ if (vshCommandOptBool(cmd, "force"))
+ flags |= VIR_DOMAIN_DEVICE_MODIFY_FORCE;
+
ret = virDomainUpdateDeviceFlags(dom, buffer, flags);
VIR_FREE(buffer);
diff --git a/tools/virsh.pod b/tools/virsh.pod
index 9cb6829..9c45a61 100644
--- a/tools/virsh.pod
+++ b/tools/virsh.pod
@@ -731,12 +731,14 @@ I<type> can be either I<network> to indicate a physical network device or I<brid
It is recommended to use the I<mac> option to distinguish between the interfaces
if more than one are present on the domain.
-=item B<update-device> I<domain-id> I<file> optional I<--persistent>
-
-Update the characteristics of a device associated with I<domain-id>,
-based on the device definition in an XML I<file>. If the I<--persistent>
-option is used, the changes will affect the next boot of the domain.
-See the documentation to learn about libvirt XML format for a device.
+=item B<update-device> I<domain-id> I<file> optional I<--persistent> I<--force>
+
+Update the characteristics of a device associated with I<domain-id>, based on
+the device definition in an XML I<file>. If the I<--persistent> option is
+used, the changes will affect the next boot of the domain. The I<--force>
+option can be used to force device update, e.g., to eject a CD-ROM even if it
+is locked/mounted in the domain. See the documentation to learn about libvirt
+XML format for a device.
=back
--
1.7.3.4
14 years
[libvirt] [PATCH] fix virsh coredumps when using ext transport
by Wen Congyang
when we use an external process to connect remote libvirtd,
virsh will coredump:
# virsh -c qemu+ext://<target_ip>/system?command=cmd
Segmentation fault (core dumped)
This bug was caused by 3348a97b.
Signed-off-by: Wen Congyang <wency(a)cn.fujitsu.com>
---
src/remote/remote_driver.c | 12 ++++++++++++
1 files changed, 12 insertions(+), 0 deletions(-)
diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
index fae191c..1c13f4a 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -802,6 +802,18 @@ doRemoteOpen (virConnectPtr conn,
goto failed;
}
+ /* Run the external process. */
+ if (!cmd_argv) {
+ if (VIR_ALLOC_N(cmd_argv, 2) < 0)
+ goto out_of_memory;
+
+ cmd_argv[0] = strdup(command);
+ if (cmd_argv[0] == NULL)
+ goto out_of_memory;
+
+ cmd_argv[1] = NULL;
+ }
+
if (virExec((const char**)cmd_argv, NULL, NULL,
&pid, sv[1], &(sv[1]), &(errfd[1]),
VIR_EXEC_CLEAR_CAPS) < 0)
--
1.7.1
14 years
[libvirt] [PATCH] Fix memory leak in virsh
by Hu Tao
---
tools/virsh.c | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/tools/virsh.c b/tools/virsh.c
index 4e37f2d..8c123bb 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -10935,8 +10935,10 @@ vshCommandParse(vshControl *ctl, vshCommandParser *parser)
if (tk == VSH_TK_ERROR)
goto syntaxError;
- if (tk != VSH_TK_ARG)
+ if (tk != VSH_TK_ARG) {
+ VIR_FREE(tkdata);
break;
+ }
if (cmd == NULL) {
/* first token must be command name */
--
1.7.3.1
--
Thanks,
Hu Tao
14 years