[libvirt] Python script and extension module directory handling
by Matthias Bolte
Commit 66137344feb488ea87b0d92f3c03844d9a7a7786 changed the Python
detection mechanism in configure. This results in a changed install
location for the Python bindings at least on Fedora 12 64bit systems.
For the explanation below I assume a Fedora 12 64bit systems, libvirt
is configured with prefix /usr and Python 2.6 is installed.
Before this commit libvirt.py and libvirtmod.so were installed to
/usr/lib64/python2.6/site-packages. After this commit both are
installed to /usr/lib/python2.6/site-packages. This is at least wrong
for libvirtmod.so, as it should be installed to
/usr/lib64/python2.6/site-packages on a 64bit system.
Before this commit pythondir was set manually to
/usr/lib64/python2.6/site-packages and python/Makefile.am contains
'python_LTLIBRARIES = libvirtmod.la' that results in installing
libvirtmod.so to pythondir.
AM_PATH_PYTHON defines two variables: pythondir and pyexecdir. But
according to the AM_PATH_PYTHON documentation [1] pythondir is the
directory where Python scripts should be installed.
/usr/lib/python2.6/site-packages in this case, because Python scripts
are not architecture dependent in general. pyexecdir is the directory
where Python extension modules (shared libraries) should be installed.
AM_PATH_PYTHON detects pyexecdir correctly as
/usr/lib64/python2.6/site-packages, but python/Makefile.am contains
'python_LTLIBRARIES = libvirtmod.la' that results in installing
libvirtmod.so to pythondir.
So python/Makefile.am must be changed:
diff --git a/python/Makefile.am b/python/Makefile.am
index 736631e..04342b7 100644
--- a/python/Makefile.am
+++ b/python/Makefile.am
@@ -32,7 +32,7 @@ mylibs = $(top_builddir)/src/libvirt.la
all-local: libvirt.py
-python_LTLIBRARIES = libvirtmod.la
+pyexec_LTLIBRARIES = libvirtmod.la
libvirtmod_la_SOURCES = libvirt-override.c typewrappers.c libvirt.c libvirt.h
# Python <= 2.4 header files contain a redundant decl, hence we
Now libvirtmod.so is installed to the correct directory:
/usr/lib64/python2.6/site-packages
But libvirt.py gets installed to /usr/lib/python2.6/site-packages,
this is different from the installation directory before the commit.
A default Fedora 12 64bit installation has *.py files installed to
/usr/lib/python2.6/site-packages and
/usr/lib64/python2.6/site-packages. By looking at both directories the
policy it pretty obvious: Packages that are pure Python go to
/usr/lib/python2.6/site-packages and packages that are mixed (Python
and shared libraries) go completely to
/usr/lib64/python2.6/site-packages.
So we restore the behavior from before the commit completely by
applying this additional patch:
diff --git a/python/Makefile.am b/python/Makefile.am
index 736631e..04342b7 100644
--- a/python/Makefile.am
+++ b/python/Makefile.am
@@ -60,14 +60,14 @@ $(GENERATED): generated.stamp
$(libvirtmod_la_OBJECTS): $(GENERATED)
install-data-local:
- $(mkinstalldirs) $(DESTDIR)$(pythondir)
- @INSTALL@ -m 0644 libvirt.py $(DESTDIR)$(pythondir)
+ $(mkinstalldirs) $(DESTDIR)$(pyexecdir)
+ @INSTALL@ -m 0644 libvirt.py $(DESTDIR)$(pyexecdir)
$(mkinstalldirs) $(DESTDIR)$(DOCS_DIR)
@(for doc in $(DOCS) ; \
do @INSTALL@ -m 0644 $$doc $(DESTDIR)$(DOCS_DIR) ; done)
uninstall-local:
- rm -f $(DESTDIR)$(pythondir)/libvirt.py
+ rm -f $(DESTDIR)$(pyexecdir)/libvirt.py
CLEANFILES= $(GENERATED) generated.stamp
I discussed this with Daniel Veillard on IRC and there was some
confusion what the actual problem was and how to solve it, so I wanted
to recap it here.
Also thanks to Daniel Hokka Zakrisson, who gave the important hint
about pythondir vs pyexecdir on IRC.
[1] http://www.gnu.org/software/hello/manual/automake/Python.html
Matthias
15 years, 4 months
[libvirt] [PATCH] node_device_driver.c: don't write beyond EOB for 4K-byte symlink
by Jim Meyering
Without this patch, a symlink pointing to a 4096-byte name
could make this code write NUL into the byte beyond end of buffer:
if ((n = readlink(driver_link, devpath, sizeof devpath - 1)) < 0) {
virReportSystemError(conn, errno,
_("cannot resolve driver link %s"), driver_link);
goto cleanup;
}
devpath[n] = '\0';
>From a075e207bc8fb279c43c9f4f43a960ffbd9a8a70 Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering(a)redhat.com>
Date: Mon, 14 Dec 2009 12:05:38 +0100
Subject: [PATCH] node_device_driver.c: don't write beyond EOB for 4K-byte symlink
* src/node_device/node_device_driver.c (update_driver_name): Leave
one byte for the trailing NUL we'll append.
---
src/node_device/node_device_driver.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/src/node_device/node_device_driver.c b/src/node_device/node_device_driver.c
index f083f16..eda5d5e 100644
--- a/src/node_device/node_device_driver.c
+++ b/src/node_device/node_device_driver.c
@@ -97,7 +97,7 @@ static int update_driver_name(virConnectPtr conn,
goto cleanup;
}
- if ((n = readlink(driver_link, devpath, sizeof devpath)) < 0) {
+ if ((n = readlink(driver_link, devpath, sizeof devpath - 1)) < 0) {
virReportSystemError(conn, errno,
_("cannot resolve driver link %s"), driver_link);
goto cleanup;
--
1.6.6.rc2.275.g51e2d
15 years, 4 months
[libvirt] [PATCH] Allow versioned pc machines for QEmu
by Diego Elio Pettenò
* docs/schemas/domain.rng: add pattern for pc-0.10, pc-0.11 and similar
machine types
---
docs/schemas/domain.rng | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/docs/schemas/domain.rng b/docs/schemas/domain.rng
index d1d3efb..dd3f732 100644
--- a/docs/schemas/domain.rng
+++ b/docs/schemas/domain.rng
@@ -171,6 +171,9 @@
<value>xenfv</value>
<value>pc</value>
<value>isapc</value>
+ <data type="string">
+ <param name="pattern">pc-[0-9\.]+</param>
+ </data>
</choice>
</attribute>
</optional>
--
1.6.5.6
15 years, 4 months
[libvirt] [PATCH] Fix owner and group in example volume XML
by Matthew Booth
The owner and group in the documentation examples were confusingly given as
'0744'. They should be numeric uid and gid. Changed the examples to use the
default uid and gid assigned to qemu in F12.
* docs/formatstorage.html.in: Change example owner and group in volume XML
---
docs/formatstorage.html.in | 16 ++++++++--------
1 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/docs/formatstorage.html.in b/docs/formatstorage.html.in
index ccf5a91..5c41c39 100644
--- a/docs/formatstorage.html.in
+++ b/docs/formatstorage.html.in
@@ -119,8 +119,8 @@
<target>
<path>/dev/disk/by-path</path>
<permissions>
- <owner>0744</owner>
- <group>0744</group>
+ <owner>107</owner>
+ <group>107</group>
<mode>0744</mode>
<label>virt_image_t</label>
</permissions>
@@ -244,8 +244,8 @@
<path>/var/lib/virt/images/sparse.img</path>
<format type='qcow2'/>
<permissions>
- <owner>0744</owner>
- <group>0744</group>
+ <owner>107</owner>
+ <group>107</group>
<mode>0744</mode>
<label>virt_image_t</label>
</permissions>
@@ -294,8 +294,8 @@
<path>/var/lib/virt/images/master.img</path>
<format>raw</format>
<permissions>
- <owner>0744</owner>
- <group>0744</group>
+ <owner>107</owner>
+ <group>107</group>
<mode>0744</mode>
<label>virt_image_t</label>
</permissions>
@@ -368,8 +368,8 @@
<target>
<path>/var/lib/virt/images/sparse.img</path>
<permissions>
- <owner>0744</owner>
- <group>0744</group>
+ <owner>107</owner>
+ <group>107</group>
<mode>0744</mode>
<label>virt_image_t</label>
</permissions>
--
1.6.5.2
15 years, 5 months
[libvirt] [PATCH] Eliminate failure to delete empty storage pools
by Laine Stump
virStorageBackendFileSystemDelete was incorrectly calling unlink() in
an attempt to remove a directory. It should be calling rmdir()
instead. (remove() would also work, but could potentially succeed on a
non-empty pool if the pool was a symlink to somewhere else).
---
src/storage/storage_backend_fs.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/storage/storage_backend_fs.c b/src/storage/storage_backend_fs.c
index 16e4bd9..b7d4bd6 100644
--- a/src/storage/storage_backend_fs.c
+++ b/src/storage/storage_backend_fs.c
@@ -693,9 +693,9 @@ virStorageBackendFileSystemDelete(virConnectPtr conn,
{
/* XXX delete all vols first ? */
- if (unlink(pool->def->target.path) < 0) {
+ if (rmdir(pool->def->target.path) < 0) {
virReportSystemError(conn, errno,
- _("cannot unlink path '%s'"),
+ _("failed to remove pool '%s'"),
pool->def->target.path);
return -1;
}
--
1.6.6.rc2.5.g49666
15 years, 5 months
[libvirt] [PATCH] Fix use of virEventAddHandleImpl()
by Jiri Denemark
Signed-off-by: Jiri Denemark <jdenemar(a)redhat.com>
---
src/node_device/node_device_udev.c | 10 +++++-----
1 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_device_udev.c
index cf23be1..6b6e244 100644
--- a/src/node_device/node_device_udev.c
+++ b/src/node_device/node_device_udev.c
@@ -37,7 +37,7 @@
#include "uuid.h"
#include "util.h"
#include "buf.h"
-#include "daemon/event.h"
+#include "event.h"
#define VIR_FROM_THIS VIR_FROM_NODEDEV
@@ -1526,10 +1526,10 @@ static int udevDeviceMonitorStartup(int privileged ATTRIBUTE_UNUSED)
* enumeration. The alternative is to register the callback after
* we enumerate, in which case we will fail to create any devices
* that appear while the enumeration is taking place. */
- if (virEventAddHandleImpl(udev_monitor_get_fd(udev_monitor),
- VIR_EVENT_HANDLE_READABLE,
- udevEventHandleCallback,
- NULL, NULL) == -1) {
+ if (virEventAddHandle(udev_monitor_get_fd(udev_monitor),
+ VIR_EVENT_HANDLE_READABLE,
+ udevEventHandleCallback,
+ NULL, NULL) == -1) {
ret = -1;
goto out;
}
--
1.6.5.6
15 years, 5 months
[libvirt] [PATCH] Cleanup temporary #define after use
by Matthew Booth
* src/qemu/qemu_driver.c: #undef LOOKUP_PTYS after use
---
src/qemu/qemu_driver.c | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 7e55c23..4567a66 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -1436,6 +1436,7 @@ qemudFindCharDevicePTYsMonitor(virConnectPtr conn,
LOOKUP_PTYS(vm->def->serials, vm->def->nserials, "serial");
LOOKUP_PTYS(vm->def->parallels, vm->def->nparallels, "parallel");
LOOKUP_PTYS(vm->def->channels, vm->def->nchannels, "channel");
+#undef LOOKUP_PTYS
return 0;
}
--
1.6.5.2
15 years, 5 months
[libvirt] [PATCH] nodedev: Add removable storage 'media_label' prop
by Cole Robinson
Provides the CDROM label for current media. Only implemented for the udev
backend.
Signed-off-by: Cole Robinson <crobinso(a)redhat.com>
---
docs/schemas/nodedev.rng | 5 +++++
src/conf/node_device_conf.c | 8 ++++++++
src/conf/node_device_conf.h | 1 +
src/node_device/node_device_udev.c | 5 +++++
tests/nodedevschemadata/DVD_with_media.xml | 16 ++++++++++++++++
tests/nodedevxml2xmltest.c | 1 +
6 files changed, 36 insertions(+), 0 deletions(-)
create mode 100644 tests/nodedevschemadata/DVD_with_media.xml
diff --git a/docs/schemas/nodedev.rng b/docs/schemas/nodedev.rng
index 7060274..797b1af 100644
--- a/docs/schemas/nodedev.rng
+++ b/docs/schemas/nodedev.rng
@@ -314,6 +314,11 @@
<element name='media_size'>
<ref name='uint'/>
</element>
+ <optional>
+ <element name='media_label'>
+ <text/>
+ </element>
+ </optional>
</element>
</define>
diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c
index 6003ab1..a0d256c 100644
--- a/src/conf/node_device_conf.c
+++ b/src/conf/node_device_conf.c
@@ -422,6 +422,11 @@ char *virNodeDeviceDefFormat(virConnectPtr conn,
"</media_available>\n", avl ? 1 : 0);
virBufferVSprintf(&buf, " <media_size>%llu</media_size>\n",
data->storage.removable_media_size);
+ if (data->storage.media_label)
+ virBufferVSprintf(&buf,
+ " <media_label>%s</media_label>\n",
+ data->storage.media_label);
+
if (data->storage.logical_block_size > 0)
virBufferVSprintf(&buf, " <logical_block_size>%llu"
"</logical_block_size>\n",
@@ -575,6 +580,8 @@ virNodeDevCapStorageParseXML(virConnectPtr conn,
if (virXPathBoolean(conn, "count(./media_available[. = '1']) > 0", ctxt))
data->storage.flags |= VIR_NODE_DEV_CAP_STORAGE_REMOVABLE_MEDIA_AVAILABLE;
+ data->storage.media_label = virXPathString(conn, "string(./media_label[1])", ctxt);
+
val = 0;
if (virNodeDevCapsDefParseULongLong(conn, "number(./media_size[1])", ctxt, &val, def,
_("no removable media size supplied for '%s'"),
@@ -1431,6 +1438,7 @@ void virNodeDevCapsDefFree(virNodeDevCapsDefPtr caps)
VIR_FREE(data->storage.model);
VIR_FREE(data->storage.vendor);
VIR_FREE(data->storage.serial);
+ VIR_FREE(data->storage.media_label);
break;
case VIR_NODE_DEV_CAP_LAST:
/* This case is here to shutup the compiler */
diff --git a/src/conf/node_device_conf.h b/src/conf/node_device_conf.h
index 7a20bd6..e409a76 100644
--- a/src/conf/node_device_conf.h
+++ b/src/conf/node_device_conf.h
@@ -154,6 +154,7 @@ struct _virNodeDevCapsDef {
char *model;
char *vendor;
char *serial;
+ char *media_label;
unsigned flags; /* virNodeDevStorageCapFlags bits */
} storage;
} data;
diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_device_udev.c
index 9b48052..c78643e 100644
--- a/src/node_device/node_device_udev.c
+++ b/src/node_device/node_device_udev.c
@@ -867,6 +867,11 @@ static int udevProcessCDROM(struct udev_device *device,
def->caps->data.storage.flags |=
VIR_NODE_DEV_CAP_STORAGE_REMOVABLE_MEDIA_AVAILABLE;
+ if (udevGetStringProperty(device, "ID_FS_LABEL",
+ &data->storage.media_label) == PROPERTY_ERROR) {
+ goto out;
+ }
+
if (udevGetUint64SysfsAttr(device,
"size",
&data->storage.num_blocks) == PROPERTY_ERROR) {
diff --git a/tests/nodedevschemadata/DVD_with_media.xml b/tests/nodedevschemadata/DVD_with_media.xml
new file mode 100644
index 0000000..673e88f
--- /dev/null
+++ b/tests/nodedevschemadata/DVD_with_media.xml
@@ -0,0 +1,16 @@
+<device>
+ <name>DVD_GCC_4247N</name>
+ <parent>pci_8086_27df_scsi_host_scsi_device_lun0</parent>
+ <capability type='storage'>
+ <block>/dev/sr0</block>
+ <bus>scsi</bus>
+ <drive_type>cdrom</drive_type>
+ <model>RW/DVD GCC-4247N</model>
+ <vendor>HL-DT-ST</vendor>
+ <capability type='removable'>
+ <media_available>1</media_available>
+ <media_size>12345678</media_size>
+ <media_label>Windows_XP_Label</media_label>
+ </capability>
+ </capability>
+</device>
diff --git a/tests/nodedevxml2xmltest.c b/tests/nodedevxml2xmltest.c
index 7621212..bf8be7e 100644
--- a/tests/nodedevxml2xmltest.c
+++ b/tests/nodedevxml2xmltest.c
@@ -80,6 +80,7 @@ mymain(int argc, char **argv)
DO_TEST("computer");
DO_TEST("DVD_GCC_4247N");
+ DO_TEST("DVD_with_media");
DO_TEST("net_00_13_02_b9_f9_d3");
DO_TEST("net_00_15_58_2f_e9_55");
DO_TEST("pci_1002_71c4");
--
1.6.5.2
15 years, 5 months