[libvirt] [PATCH RFC] Don't use CLONE_NEWUSER for now
by Serge E. Hallyn
Until now, user namespaces have not done much, but (for that
reason) have been innocuous to glob in with other CLONE_
flags. Upcoming userns development, however, will make tasks
cloned with CLONE_NEWUSER far more restricted. In particular,
for some time they will be unable to access files with anything
other than the world access perms.
This patch assumes that noone really needs the user namespaces
to be enabled. If that is wrong, then we can try a more
baroque patch where we create a file owned by a test userid with
700 perms and, if we can't access it after setuid'ing to that
userid, then return 0. Otherwise, assume we are using an
older, 'harmless' user namespace implementation.
Comments appreciated. Is it ok to do this?
Signed-off-by: Serge Hallyn <serge.hallyn(a)canonical.com>
---
src/lxc/lxc_container.c | 7 +++++++
1 files changed, 7 insertions(+), 0 deletions(-)
diff --git a/src/lxc/lxc_container.c b/src/lxc/lxc_container.c
index 876bc62..a735eb7 100644
--- a/src/lxc/lxc_container.c
+++ b/src/lxc/lxc_container.c
@@ -810,7 +810,14 @@ static int lxcContainerChild( void *data )
static int userns_supported(void)
{
+#if 1
+ /*
+ * put off using userns until uid mapping is implemented
+ */
+ return 0;
+#else
return lxcContainerAvailable(LXC_CONTAINER_FEATURE_USER) == 0;
+#endif
}
/**
--
1.7.2.3
13 years, 9 months
[libvirt] [PATCH v2] storage: Allow to delete device mapper disk partition
by Osier Yang
The name convention of device mapper disk is different, and 'parted'
can't be used to delete a device mapper disk partition. e.g.
# virsh vol-list --pool osier
Name Path
-----------------------------------------
3600a0b80005ad1d7000093604cae912fp1 /dev/mapper/3600a0b80005ad1d7000093604cae912fp1
# parted /dev/mapper/3600a0b80005adb0b0000ab2d4cae9254 rm p1
Error: Expecting a partition number.
This patch introduces 'dmsetup' to fix it.
Changes:
- New function "virIsDevMapperDevice" in "src/utils/utils.c"
- remove "is_dm_device" in "src/storage/parthelper.c", use
"virIsDevMapperDevice" instead.
- Requires "device-mapper" for 'with-storage-disk" in "libvirt.spec.in"
- Check "dmsetup" in 'configure.ac' for "with-storage-disk"
- Changes on "src/Makefile.am" to link against libdevmapper
- New entry for "virIsDevMapperDevice" in "src/libvirt_private.syms"
Changes from v1 to v2:
- s/virIsDeviceMapperDevice/virIsDevMapperDevice/g
- replace "virRun" with "virCommand"
- sort the list of util functions in "libvirt_private.syms"
e.g.
# virsh vol-list --pool osier
Name Path
-----------------------------------------
3600a0b80005ad1d7000093604cae912fp1 /dev/mapper/3600a0b80005ad1d7000093604cae912fp1
# virsh vol-delete /dev/mapper/3600a0b80005ad1d7000093604cae912fp1
Vol /dev/mapper/3600a0b80005ad1d7000093604cae912fp1 deleted
# virsh vol-list --pool osier
Name Path
-----------------------------------------
---
configure.ac | 19 ++++++++++++++
libvirt.spec.in | 1 +
src/Makefile.am | 8 +++---
src/libvirt_private.syms | 5 ++-
src/storage/parthelper.c | 14 +---------
src/storage/storage_backend_disk.c | 48 +++++++++++++++++++++--------------
src/util/util.c | 14 ++++++++++
src/util/util.h | 2 +
8 files changed, 73 insertions(+), 38 deletions(-)
diff --git a/configure.ac b/configure.ac
index 8a4083f..9517bfc 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1706,12 +1706,19 @@ LIBPARTED_LIBS=
if test "$with_storage_disk" = "yes" ||
test "$with_storage_disk" = "check"; then
AC_PATH_PROG([PARTED], [parted], [], [$PATH:/sbin:/usr/sbin])
+ AC_PATH_PROG([DMSETUP], [dmsetup], [], [$PATH:/sbin:/usr/sbin])
if test -z "$PARTED" ; then
PARTED_FOUND=no
else
PARTED_FOUND=yes
fi
+ if test -z "$DMSETUP" ; then
+ DMSETUP_FOUND=no
+ else
+ DMSETUP_FOUND=yes
+ fi
+
if test "$PARTED_FOUND" = "yes" && test "x$PKG_CONFIG" != "x" ; then
PKG_CHECK_MODULES([LIBPARTED], [libparted >= $PARTED_REQUIRED], [],
[PARTED_FOUND=no])
@@ -1739,11 +1746,23 @@ if test "$with_storage_disk" = "yes" ||
with_storage_disk=yes
fi
+ if test "$DMSETUP_FOUND" = "no" ; then
+ if test "$with_storage_disk" = "yes" ; then
+ AC_MSG_ERROR([We need dmsetup for disk storage driver])
+ else
+ with_storage_disk=no
+ fi
+ else
+ with_storage_disk=yes
+ fi
+
if test "$with_storage_disk" = "yes"; then
AC_DEFINE_UNQUOTED([WITH_STORAGE_DISK], 1,
[whether Disk backend for storage driver is enabled])
AC_DEFINE_UNQUOTED([PARTED],["$PARTED"],
[Location or name of the parted program])
+ AC_DEFINE_UNQUOTED([DMSETUP],["$DMSETUP"],
+ [Location or name of the dmsetup program])
fi
fi
AM_CONDITIONAL([WITH_STORAGE_DISK], [test "$with_storage_disk" = "yes"])
diff --git a/libvirt.spec.in b/libvirt.spec.in
index 0a2d10e..27e6a99 100644
--- a/libvirt.spec.in
+++ b/libvirt.spec.in
@@ -279,6 +279,7 @@ Requires: iscsi-initiator-utils
%if %{with_storage_disk}
# For disk driver
Requires: parted
+Requires: device-mapper
%endif
%if %{with_storage_mpath}
# For multipath support
diff --git a/src/Makefile.am b/src/Makefile.am
index f8b8434..a8848bb 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -437,9 +437,9 @@ libvirt_la_BUILT_LIBADD = libvirt_util.la
libvirt_util_la_SOURCES = \
$(UTIL_SOURCES)
libvirt_util_la_CFLAGS = $(CAPNG_CFLAGS) $(YAJL_CFLAGS) $(LIBNL_CFLAGS) \
- $(AM_CFLAGS) $(AUDIT_CFLAGS)
+ $(AM_CFLAGS) $(AUDIT_CFLAGS) $(DEVMAPPER_CFLAGS)
libvirt_util_la_LIBADD = $(CAPNG_LIBS) $(YAJL_LIBS) $(LIBNL_LIBS) \
- $(LIB_PTHREAD) $(AUDIT_LIBS)
+ $(LIB_PTHREAD) $(AUDIT_LIBS) $(DEVMAPPER_LIBS)
noinst_LTLIBRARIES += libvirt_conf.la
@@ -1154,7 +1154,6 @@ libvirt_parthelper_SOURCES = $(STORAGE_HELPER_DISK_SOURCES)
libvirt_parthelper_LDFLAGS = $(WARN_LDFLAGS) $(AM_LDFLAGS)
libvirt_parthelper_LDADD = \
$(LIBPARTED_LIBS) \
- $(DEVMAPPER_LIBS) \
libvirt_util.la \
../gnulib/lib/libgnu.la
@@ -1179,7 +1178,8 @@ libvirt_lxc_SOURCES = \
libvirt_lxc_LDFLAGS = $(WARN_CFLAGS) $(AM_LDFLAGS)
libvirt_lxc_LDADD = $(CAPNG_LIBS) $(YAJL_LIBS) \
$(LIBXML_LIBS) $(NUMACTL_LIBS) $(LIB_PTHREAD) \
- $(LIBNL_LIBS) $(AUDIT_LIBS) ../gnulib/lib/libgnu.la
+ $(LIBNL_LIBS) $(AUDIT_LIBS) $(DEVMAPPER_LIBS) \
+ ../gnulib/lib/libgnu.la
libvirt_lxc_CFLAGS = \
$(LIBPARTED_CFLAGS) \
$(NUMACTL_CFLAGS) \
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 88e270c..63bd721 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -881,6 +881,7 @@ virGetUserID;
virGetUserName;
virHexToBin;
virIndexToDiskName;
+virIsDevMapperDevice;
virKillProcess;
virMacAddrCompare;
virParseMacAddr;
@@ -895,6 +896,8 @@ virSetCloseExec;
virSetNonBlock;
virSetUIDGID;
virSkipSpaces;
+virStrcpy;
+virStrncpy;
virStrToDouble;
virStrToLong_i;
virStrToLong_l;
@@ -902,8 +905,6 @@ virStrToLong_ll;
virStrToLong_ui;
virStrToLong_ul;
virStrToLong_ull;
-virStrcpy;
-virStrncpy;
virTimestamp;
virVasprintf;
diff --git a/src/storage/parthelper.c b/src/storage/parthelper.c
index 6ef413d..acc9171 100644
--- a/src/storage/parthelper.c
+++ b/src/storage/parthelper.c
@@ -59,18 +59,6 @@ enum diskCommand {
DISK_GEOMETRY
};
-static int
-is_dm_device(const char *devname)
-{
- struct stat buf;
-
- if (devname && !stat(devname, &buf) && dm_is_dm_major(major(buf.st_rdev))) {
- return 1;
- }
-
- return 0;
-}
-
int main(int argc, char **argv)
{
PedDevice *dev;
@@ -96,7 +84,7 @@ int main(int argc, char **argv)
}
path = argv[1];
- if (is_dm_device(path)) {
+ if (virIsDevMapperDevice(path)) {
partsep = "p";
canonical_path = strdup(path);
if (canonical_path == NULL) {
diff --git a/src/storage/storage_backend_disk.c b/src/storage/storage_backend_disk.c
index c7ade6b..05eb8c3 100644
--- a/src/storage/storage_backend_disk.c
+++ b/src/storage/storage_backend_disk.c
@@ -31,6 +31,7 @@
#include "storage_backend_disk.h"
#include "util.h"
#include "memory.h"
+#include "command.h"
#include "configmake.h"
#define VIR_FROM_THIS VIR_FROM_STORAGE
@@ -647,6 +648,7 @@ virStorageBackendDiskDeleteVol(virConnectPtr conn ATTRIBUTE_UNUSED,
char *part_num = NULL;
char *devpath = NULL;
char *devname, *srcname;
+ virCommandPtr cmd = NULL;
int rc = -1;
if (virFileResolveLink(vol->target.path, &devpath) < 0) {
@@ -660,38 +662,46 @@ virStorageBackendDiskDeleteVol(virConnectPtr conn ATTRIBUTE_UNUSED,
srcname = basename(pool->def->source.devices[0].path);
DEBUG("devname=%s, srcname=%s", devname, srcname);
- if (!STRPREFIX(devname, srcname)) {
+ if (!virIsDevMapperDevice(devpath) && !STRPREFIX(devname, srcname)) {
virStorageReportError(VIR_ERR_INTERNAL_ERROR,
_("Volume path '%s' did not start with parent "
"pool source device name."), devname);
goto cleanup;
}
- part_num = devname + strlen(srcname);
+ if (!virIsDevMapperDevice(devpath)) {
+ part_num = devname + strlen(srcname);
- if (*part_num == 0) {
- virStorageReportError(VIR_ERR_INTERNAL_ERROR,
- _("cannot parse partition number from target "
- "'%s'"), devname);
- goto cleanup;
- }
+ if (*part_num == 0) {
+ virStorageReportError(VIR_ERR_INTERNAL_ERROR,
+ _("cannot parse partition number from target "
+ "'%s'"), devname);
+ goto cleanup;
+ }
- /* eg parted /dev/sda rm 2 */
- const char *prog[] = {
- PARTED,
- pool->def->source.devices[0].path,
- "rm",
- "--script",
- part_num,
- NULL,
- };
+ cmd = virCommandNew(PARTED);
+ virCommandAddArgList(cmd,
+ pool->def->source.devices[0].path,
+ "rm",
+ "--script",
+ part_num,
+ NULL);
- if (virRun(prog, NULL) < 0)
- goto cleanup;
+ if (virCommandRun(cmd, NULL) < 0)
+ goto cleanup;
+ } else {
+ cmd = virCommandNew(DMSETUP);
+ virCommandAddArgList(cmd, "remove", "--force", devpath, NULL);
+
+ if (virCommandRun(cmd, NULL) < 0)
+ goto cleanup;
+ }
rc = 0;
+
cleanup:
VIR_FREE(devpath);
+ virCommandFree(cmd);
return rc;
}
diff --git a/src/util/util.c b/src/util/util.c
index ee04ca9..fc2e0c9 100644
--- a/src/util/util.c
+++ b/src/util/util.c
@@ -45,6 +45,7 @@
#include <string.h>
#include <signal.h>
#include <termios.h>
+#include <libdevmapper.h>
#include "c-ctype.h"
#ifdef HAVE_PATHS_H
@@ -3100,3 +3101,16 @@ virTimestamp(void)
return timestamp;
}
+
+bool
+virIsDevMapperDevice(const char *devname)
+{
+ struct stat buf;
+
+ if (devname &&
+ !stat(devname, &buf) &&
+ dm_is_dm_major(major(buf.st_rdev)))
+ return true;
+
+ return false;
+}
diff --git a/src/util/util.h b/src/util/util.h
index 8373038..280f86e 100644
--- a/src/util/util.h
+++ b/src/util/util.h
@@ -296,4 +296,6 @@ int virBuildPathInternal(char **path, ...) ATTRIBUTE_SENTINEL;
char *virTimestamp(void);
+bool virIsDevMapperDevice(const char *devname);
+
#endif /* __VIR_UTIL_H__ */
--
1.7.3.2
13 years, 9 months
[libvirt] [libvirt-php 0/2] Introduce set_error() function and fix compilation warnings
by Michal Novotny
Hi,
this is the patch to introduce set_error() function to be able to set error from
everywhere we want (and not just using the libvirt error handler), e.g. when the
API function is not available in the libvirt version the user is using. Also, the
formatting and error handling has been fixed.
Second part of the patch is fixing the compilation warnings. Patch has been tested
on Fedora 14 box using php 5.3.4-1 version of Fedora 14 and it was working as
designed.
Michal
Signed-off-by: Michal Novotny <minovotn(a)redhat.com>
Michal Novotny (2):
Introduce set_error() function and fix error handling/formatting
Fix compilation warnings
libvirt.c | 382 ++++++++++++++++++++++++++++++++-------------------------
php_libvirt.h | 4 -
2 files changed, 212 insertions(+), 174 deletions(-)
--
1.7.3.2
13 years, 9 months
[libvirt] Strange nodedev-dumpxml ??
by arnaud.champion@devatom.fr
?Hi,
I have maybe a strange thing on a nodedev-dumpxml virsh result :
virsh # nodedev-dumpxml block_sr0
<device>
<name>block_sr0</name>
<parent>scsi_0_0_1_0</parent>
<capability type='storage'>
<block>/dev/sr0</block>
<bus>scsi</bus>
<drive_type>cdrom</drive_type>
<model>DVD RW DRU-190S</model>
<vendor>SONY</vendor>
<capability type='removable'>
<media_available>0</media_available>
<media_size>0</media_size>
</capability>
</capability>
</device>
I think (note I'm not sure), the capabilty type removable should be in the device element, like this :
virsh # nodedev-dumpxml block_sr0
<device>
<name>block_sr0</name>
<parent>scsi_0_0_1_0</parent>
<capability type='storage'>
<block>/dev/sr0</block>
<bus>scsi</bus>
<drive_type>cdrom</drive_type>
<model>DVD RW DRU-190S</model>
<vendor>SONY</vendor>
</capability>
<capability type='removable'>
<media_available>0</media_available>
<media_size>0</media_size>
</capability>
</device>
Let me know if I'm wrong.
13 years, 9 months
[libvirt] [PATCH] docs: Clarify usage of vram and heads
by Osier Yang
Though attributes "vram" and "heads" of "video" element are generic,
they are only useful for vbox driver currently.
* docs/formatdomain.html.in
---
docs/formatdomain.html.in | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index 43c78fc..c130460 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -1572,6 +1572,8 @@ qemu-kvm -net nic,model=? /dev/null
"xen" or "vbox", depending on the hypervisor features available.
You can also provide the amount of video memory in kilobytes using
<code>vram</code> and the number of screen with <code>heads</code>.
+ NB, though <code>vram</code> and <code>heads</code> are generic
+ attributes, they are only useful for vbox driver.
</dd>
<dt><code>acceleration</code></dt>
--
1.7.3.2
13 years, 9 months
[libvirt] [PATCH libvirt-site] Add libvirt-php information page
by Michal Novotny
Hi,
this is the patch to add libvirt-php information page with some
basic information on libvirt-php project compilation, contribution
and other useful information.
Michal
Signed-off-by: Michal Novotny <minovotn(a)redhat.com>
---
docs/bindings.html.in | 13 ++++---
docs/php.html.in | 85 +++++++++++++++++++++++++++++++++++++++++++++++++
docs/sitemap.html.in | 4 ++
3 files changed, 96 insertions(+), 6 deletions(-)
create mode 100644 docs/php.html.in
diff --git a/docs/bindings.html.in b/docs/bindings.html.in
index 41114f0..87d894d 100644
--- a/docs/bindings.html.in
+++ b/docs/bindings.html.in
@@ -27,16 +27,17 @@
</li>
<li>
<p>
- <strong>PHP</strong>: Radek Hladik develops
- <a href="http://phplibvirt.cybersales.cz/">PHP bindings</a>.
+ <strong>PHP</strong>: Radek Hladik started developing
+ <a href="http://phplibvirt.cybersales.cz/">PHP bindings</a> in 2010.
</p>
<p>
- The php-libvirt bindings also have their source online
- <a href="http://github.com/Kedarius/php-libvirt">here in Github</a>.
+ In February 2011 the binding development has been moved to the
+ <a href="http://libvirt.org/git/?p=libvirt-php.git;a=summary">libvirt.org as libvirt-php project</a>.
</p>
<p>
- This allows you to easily see the code, make comments on it,
- create your own forks, and contribute the changes back.
+ The project is now maintained by Michal Novotny and it's heavily based
+ on Radek's version. For more information including the information on posting
+ the patches you to libvirt-php please refer to <a href="php.html">PHP binding page</a>.
</p>
</li>
<li>
diff --git a/docs/php.html.in b/docs/php.html.in
new file mode 100644
index 0000000..ea4f76a
--- /dev/null
+++ b/docs/php.html.in
@@ -0,0 +1,85 @@
+<?xml version="1.0"?>
+<html>
+ <body>
+ <h1>PHP API bindings</h1>
+
+<h2>Presentation</h2>
+ <p>The libvirt-php, originally called php-libvirt, is the PHP API bindings for
+ the libvirt virtualization toolkit originally developed by Radek Hladik but
+ currently maintained by Red Hat.</p>
+
+<h2>Getting the source</h2>
+<p> The PHP bindings code source is now maintained in a <a
+href="http://git-scm.com/">git</a> repository available on
+<a href="http://libvirt.org/git/">libvirt.org</a>:
+</p>
+<pre>
+git clone git://libvirt.org/libvirt-php.git
+</pre>
+<p>
+It can also be browsed at
+</p>
+<pre>
+<a href="http://libvirt.org/git/?p=libvirt-php.git;a=summary">http://libvirt.org/git/?p=libvirt-php.git;a=summary</a>
+</pre>
+
+<p></p>
+<h2>Building</h2>
+<p>The code is using autotools to generate the files necessary for compilation. The preferred way of building is
+ to run autogen.sh to generate configure script and then go on with the standard linux make commands, i.e.</p>
+
+<pre>
+$ cd libvirt-php
+$ ./autogen.sh
+$ make
+</pre>
+
+
+<h2>Enabling the module in PHP</h2>
+<p>Before you start using the module you have to install the module first. The module
+php_libvirt.so is being generated when you compile it. This is necessary to be loaded
+in the extensions sections of php.ini file for PHP version older than PHP-5.</p>
+<p>
+Starting with PHP-5 you can create a file called libvirt.ini in /etc/php.d having just
+one line <code>extension=php_libvirt.so</code> to enable the extension. Of course, you
+need to have this module copied in the directory with the rest of your PHP modules to
+make PHP find the module for you.</p>
+<p>
+If you're using PHP as a module (mod_php5.so) in the Apache webserver you need to
+restart your Apache to trigger configuration reload for PHP.
+</p>
+<p>
+If you're not sure that you have everything set up right and you don't want to restart
+your Apache webserver before you're sure everything will be working fine you could try
+running the test using cli-based PHP interpreter. There are some example scripts coming
+along the source codes in the <code>example</code> subdirectory so you can try to run
+php on the index.php script to check whether it's working fine to establish connection or not.
+</p>
+<p>
+When you're having some issues with the connection make sure the apache user is having
+access to libvirt. For more information please see <a href="auth.html">Libvirt access control</a> page.
+</p>
+<h2>Contribution</h2>
+<p>
+If you would like to contribute to the libvirt-php project you could write patches for it but please
+make sure you're following the procedure below:
+
+<ol>
+ <li>Sign up to libvirt list if you're not on it yet (libvir-list(a)redhat.com)</li>
+ <li>Clone the repository from libvirt.org site using:
+ <pre>git clone git://libvirt.org/libvirt-php</pre>
+ </li>
+ <li>Set your git username and e-mail and also set the subject prefix in the project's repository using:
+ <pre>git config --local format.subjectprefix "libvirt-php"</pre>
+ </li>
+ <li>Create the patch in the form of the commits and include also information about usage (example source codes maybe) and testing</li>
+ <li>Format it using <code>git format-patch -X</code> where X is the number of patch parts to be posted, for multipart patch (X is greater than 1) please use also numbering (-n) option and include the cover-letter (--cover-letter).</li>
+ <li>Send to libvir-list(a)redhat.com using the <code>git send-email <files> --to libvir-list(a)redhat.com</code> command where <files> can be <i>000*</i> to send all the patches formatted by git format-patch since git format-patch names the files starting with the 4 digit numbers.</li>
+</ol>
+
+When you send the patch you're patch will be reviewed and later committed to the libvirt-php repository. You'll be contacted in case some flaws are found during the review.
+
+</p>
+
+ </body>
+</html>
diff --git a/docs/sitemap.html.in b/docs/sitemap.html.in
index c987c49..ac0af71 100644
--- a/docs/sitemap.html.in
+++ b/docs/sitemap.html.in
@@ -266,6 +266,10 @@
<a href="csharp.html">C#</a>
<span>overview of the C# API bindings</span>
</li>
+ <li>
+ <a href="php.html">PHP</a>
+ <span>overview of the PHP API bindings</span>
+ </li>
</ul>
</li>
<li>
--
1.7.3.2
13 years, 9 months
[libvirt] [PATCH 0/6] sysinfo: expose host <sysinfo> data from virsh
by Eric Blake
First requested here:
https://www.redhat.com/archives/libvir-list/2011-January/msg00889.html
and useful enough that I coded it in one day, hopefully to be in
time for the 0.8.8 feature freeze :)
Food for thought - right now, only qemu supports this. Should I do a
followup patch that moves hostsysinfo out of qemu_conf.h and into
src/datatypes.h virConnect instead, as well as some utility routines
that make it easier for all hypervisors to choose to cache sysinfo
data (if privileged)? Compare to how many (but not all) hypervisors
share util.c virGetHostname rather than duplicating the work.
Eric Blake (6):
sysinfo: expose new API
sysinfo: define internal driver API
sysinfo: implement the public API
sysinfo: implement the remote protocol
sysinfo: implement virsh support
sysinfo: implement qemu support
daemon/remote.c | 25 +++++++-
daemon/remote_dispatch_args.h | 1 +
daemon/remote_dispatch_prototypes.h | 8 ++
daemon/remote_dispatch_ret.h | 1 +
daemon/remote_dispatch_table.h | 5 ++
docs/formatdomain.html.in | 4 +-
include/libvirt/libvirt.h.in | 4 +-
src/conf/domain_conf.c | 71 +-------------------
src/driver.h | 4 +
src/esx/esx_driver.c | 3 +-
src/libvirt.c | 42 +++++++++++-
src/libvirt_private.syms | 1 +
src/libvirt_public.syms | 5 ++
src/lxc/lxc_driver.c | 1 +
src/opennebula/one_driver.c | 3 +-
src/openvz/openvz_driver.c | 3 +-
src/phyp/phyp_driver.c | 3 +-
src/qemu/qemu_driver.c | 17 +++++
src/remote/remote_driver.c | 28 ++++++++-
src/remote/remote_protocol.c | 18 +++++
src/remote/remote_protocol.h | 15 ++++
src/remote/remote_protocol.x | 13 +++-
src/remote_protocol-structs | 6 ++
src/test/test_driver.c | 3 +-
src/uml/uml_driver.c | 1 +
src/util/sysinfo.c | 125 ++++++++++++++++++++++++++++++++++-
src/util/sysinfo.h | 5 +-
src/vbox/vbox_tmpl.c | 1 +
src/vmware/vmware_driver.c | 5 +-
src/xen/xen_driver.c | 1 +
src/xenapi/xenapi_driver.c | 2 +
tools/virsh.c | 33 +++++++++-
tools/virsh.pod | 5 ++
33 files changed, 377 insertions(+), 85 deletions(-)
--
1.7.4
13 years, 9 months
[libvirt] [PATCH] xen: Prevent updating device when attaching a device
by Osier Yang
When attaching a device that already exists, xend driver updates
the device with "device_configure", it causes problems (e.g. for
disk device, 'device_configure' only can be used to update device
like CDROM), on the other hand, we provide additional API
(virDomainUpdateDevice) to update device, this fix is to raise up
errors instead of updating the existed device.
* src/xen/xend_internal.c
---
src/xen/xend_internal.c | 34 +++++++++++++++++++++++++++++-----
1 files changed, 29 insertions(+), 5 deletions(-)
diff --git a/src/xen/xend_internal.c b/src/xen/xend_internal.c
index cd30336..76c7d64 100644
--- a/src/xen/xend_internal.c
+++ b/src/xen/xend_internal.c
@@ -3965,6 +3965,7 @@ xenDaemonAttachDeviceFlags(virDomainPtr domain, const char *xml,
virDomainDefPtr def = NULL;
virBuffer buf = VIR_BUFFER_INITIALIZER;
char class[8], ref[80];
+ char *target = NULL;
if ((domain == NULL) || (domain->conn == NULL) || (domain->name == NULL)) {
virXendError(VIR_ERR_INVALID_ARG, __FUNCTION__);
@@ -4029,6 +4030,11 @@ xenDaemonAttachDeviceFlags(virDomainPtr domain, const char *xml,
STREQ(def->os.type, "hvm") ? 1 : 0,
priv->xendConfigVersion, 1) < 0)
goto cleanup;
+
+ if (!(target = strdup(dev->data.disk->dst))) {
+ virReportOOMError();
+ goto cleanup;
+ }
break;
case VIR_DOMAIN_DEVICE_NET:
@@ -4038,6 +4044,14 @@ xenDaemonAttachDeviceFlags(virDomainPtr domain, const char *xml,
STREQ(def->os.type, "hvm") ? 1 : 0,
priv->xendConfigVersion, 1) < 0)
goto cleanup;
+
+ char macStr[VIR_MAC_STRING_BUFLEN];
+ virFormatMacAddr(dev->data.net->mac, macStr);
+
+ if (!(target = strdup(macStr))) {
+ virReportOOMError();
+ goto cleanup;
+ }
break;
case VIR_DOMAIN_DEVICE_HOSTDEV:
@@ -4046,6 +4060,17 @@ xenDaemonAttachDeviceFlags(virDomainPtr domain, const char *xml,
if (xenDaemonFormatSxprOnePCI(dev->data.hostdev,
&buf, 0) < 0)
goto cleanup;
+
+ virDomainDevicePCIAddress PCIAddr;
+
+ PCIAddr = dev->data.hostdev->source.subsys.u.pci;
+ virAsprintf(&target, "PCI device: %.4x:%.2x:%.2x", PCIAddr.domain,
+ PCIAddr.bus, PCIAddr.slot);
+
+ if (target == NULL) {
+ virReportOOMError();
+ goto cleanup;
+ }
} else {
virXendError(VIR_ERR_NO_SUPPORT, "%s",
_("unsupported device type"));
@@ -4065,17 +4090,16 @@ xenDaemonAttachDeviceFlags(virDomainPtr domain, const char *xml,
/* device doesn't exist, define it */
ret = xend_op(domain->conn, domain->name, "op", "device_create",
"config", sexpr, NULL);
- }
- else {
- /* device exists, attempt to modify it */
- ret = xend_op(domain->conn, domain->name, "op", "device_configure",
- "config", sexpr, "dev", ref, NULL);
+ } else {
+ virXendError(VIR_ERR_OPERATION_INVALID,
+ _("target '%s' already exists"), target);
}
cleanup:
VIR_FREE(sexpr);
virDomainDefFree(def);
virDomainDeviceDefFree(dev);
+ VIR_FREE(target);
return ret;
}
--
1.7.3.2
13 years, 9 months
[libvirt] configuring network interface
by Marcela Castro León
Hello
>
> I've a lan of virtual machine configured with bridge. I've a private lan of
4 machine, but one of them have 2 lan-card with access to internet.
Evertything works almost fine, except that I've configured on each guest the
static configuration of the bridge with the ip address, like this:
auto lo
iface lo inet loopback
auto eth6
iface eth6 inet static
address 192.168.1.41
network 192.168.1.0
netmask 255.255.255.0
gateway 192.168.1.10
But each time I, for example, define the guest, it start with a ascending
number of interface: eth6,eth7, eth8, etc, Now is initializing with eth12.
So, it doesn't get the manual configuration I've done on the
/etc/network/interfaces.
How can avoid this way of work of the number of ethernet interface the guest
start?
A way i'm trying to solve is configuring the interface trough the guest xml
definition, but the operation "define" on virsh accepted without error the
xml i've done, but the dumpxml doesn't show them, so, it doesn't work at
all.
I've followed the instruction that said the manual "Application development
guide - a guide to application development with libvirt" on page 71.
The whole definition of the VM is attached, but the related to interface is:
<interface type='bridge'>
<source bridge='br0'/>
<target dev='vnet0'/>
<protocol>
<ip address="192.168.1.41" prefix="24"/>
<route gateway="192.168.1.10"/>
</protocol>
<bridge stp="off" delay="0.01">
<interface type="ethernet" name="eth12">
<protocol>
<ip address="192.168.1.41" prefix="24"/>
<route gateway="192.168.1.10"/>
</protocol>
</interface>
</bridge>
</interface>
But after define, the dumpxml only show this part:
<interface type='bridge'>
<mac address='52:54:00:3c:92:9a'/>
<source bridge='br0'/>
</interface>
I would appreciate any help to solve the question. The problem I've is I
lost the access to the guest every time the libvirt change the name of the
interface eth1,2,3, etc.
Thank you very much.
Marcela
13 years, 9 months
[libvirt] [libvirt-php] New project on libvirt.org and information about sending patches
by Michal Novotny
Hi,
based on our yesterday conversation mainly between Radek Hladik from
cybersales.cz (who was the project's original maintainer), Justin Clift
and me we've decided to move the project from github to libvirt.org to
be GIT hosted there.
I recommend using this list for the patches to be reviewed there first.
I don't know whether we have to establish ACK procedure there or not
however posting the patches to this list may be good mainly for brief
reviews and option to explicitly NACK the patch if somebody doesn't
really like the patch (and have the good reason to don't like it, of
course :) ).
The procedure for sending patches to libvirt-php (or php-libvirt, as the
original name was - I guess both names are acceptable) is recommended to
be following:
1. Sign up to libvirt list if you're not on it yet (libvir-list(a)redhat.com)
2. Clone the repository from libvirt.org site using:
git clone git://libvirt.org/libvirt-php
3. Set your git username and e-mail and also set the subject prefix in
the project's repository using:
git config --local format.subjectprefix "libvirt-php"
4. Create the patch in the form of the commits and include also
information about usage (example source codes maybe) and testing
5. Format it using `git format-patch -X` where X is the number of patch
parts to be posted, for multipart patch (X > 1) please use also
numbering (-n) option and include the cover-letter (--cover-letter).
6. Send to libvir-list(a)redhat.com using the `git send-email <files> --to
libvir-list(a)redhat.com` command where <files> can be "000*" to send all
the patches formatted by git format-patch since git format-patch names
the files starting with the 4 digit numbers.
Michal
--
Michal Novotny<minovotn(a)redhat.com>, RHCE
Virtualization Team (xen userspace), Red Hat
13 years, 9 months