[libvirt] Libvirtd on Non Linux?
by Yushu Yao
Hi Experts,
Just wondering is it possible now to run libvirt deamon on non-linux
platforms (mainly windows and mac)? If yes, are there instructions on how to
build it. If no, what was the roadblock?
I'm trying to find a tool that can control the VMM for desktop/laptop users
under win/mac/linux. Mainly for automation of deployment of some appliances.
The best tool I've heard is libvirt, but couldn't find any doc on using it
for other platforms.
Any help is greatly appreciated.
-Yushu
15 years, 1 month
[libvirt] PATCH] Stop double free
by Mark Hamzy
This prevents a the following trap.
Program received signal SIGABRT, Aborted.
0x00000035ad830265 in raise () from /lib64/libc.so.6
(gdb) bt
#0 0x00000035ad830265 in raise () from /lib64/libc.so.6
#1 0x00000035ad831d10 in abort () from /lib64/libc.so.6
#2 0x00000035ad86a84b in __libc_message () from /lib64/libc.so.6
#3 0x00000035ad8722ef in _int_free () from /lib64/libc.so.6.
#4 0x00000035ad87273b in free () from /lib64/libc.so.6.
#5 0x00000000004066f1 in vshDeinit ()
#6 0x0000000000406925 in vshError ())
#7 0x0000000000406744 in vshDeinit ()
#8 0x00000000004130be in main ()
---
src/virsh.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/src/virsh.c b/src/virsh.c
index 4825f1c..5fc6c8f 100644
--- a/src/virsh.c
+++ b/src/virsh.c
@@ -8201,7 +8201,7 @@ vshError(vshControl *ctl, int doexit, const char
*format, ...)
fputc('\n', stderr);
if (doexit) {
- if (ctl)
+ if (ctl && ctl->conn)
vshDeinit(ctl);
exit(EXIT_FAILURE);
}
--
1.6.4.1
--
Mark
You must be the change you wish to see in the world. -- Mahatma Gandhi
Worrying is praying for that you do not wish to happen.
15 years, 1 month
[libvirt] Error messages with --debug
by Fred Leeflang
Oh, regarding my previous post, I ran virt-manager --debug so see what's
going on (I'm missing much more than just the vm names). I'm thinking I
either missed installing some bits or my gtk/glade setup is already obsolete
(Debian Lenny). Any hints?
(virt-manager.py:27842): libglade-WARNING **: unknown property `orientation'
for class `GtkVBox'
(virt-manager.py:27842): libglade-WARNING **: could not look up stock id
'Restore saved machine...'
(virt-manager.py:27842): libglade-WARNING **: could not look up stock id
'Add Connection...'
(virt-manager.py:27842): libglade-WARNING **: could not look up stock id
'Virtual Machine Details'
(virt-manager.py:27842): libglade-WARNING **: could not look up stock id
'Delete'
(virt-manager.py:27842): libglade-WARNING **: could not look up stock id
'_Contents'
(virt-manager.py:27842): libglade-WARNING **: unknown property `orientation'
for class `GtkVBox'
/usr/local/share/virt-manager/virtManager/manager.py:150: GtkWarning:
gtk_toolbar_set_icon_size: assertion `icon_size != GTK_ICON_SIZE_INVALID'
failed
self.window = gtk.glade.XML(config.get_glade_dir() + "/vmm-manager.glade",
"vmm-manager", domain="virt-manager")
/usr/local/share/virt-manager/virtManager/manager.py:394: GtkWarning: Failed
to set text from markup due to error parsing markup: Attribute 'font' is not
allowed on the <span> tag on line 1 char 40
win.show_all()
/usr/local/share/virt-manager/virt-manager.py:371: GtkWarning: Failed to set
text from markup due to error parsing markup: Attribute 'font' is not
allowed on the <span> tag on line 1 char 24
gtk.main()
/usr/local/share/virt-manager/virt-manager.py:371: GtkWarning: Failed to set
text from markup due to error parsing markup: Attribute 'font' is not
allowed on the <span> tag on line 1 char 25
gtk.main()
15 years, 1 month
[libvirt] Screenshot
by Fred Leeflang
Hi,
Got my git/hg builds of libvirtd/virt-manager running together with kvm.
Took some time but finally think I'm getting the
hang of it.
I noticed two things going from my pre-packaged Debian packages.
The older xml files I had seemed to generate a faulty kvm cmdline:
<disk type='file' device='cdrom'>
<target dev='hdc' bus='ide'/>
<readonly/>
</disk>
This seems to translate into a -drive file=,... The file argument for kvm
may be empty but should then not be defined:
"If you don’t specify the "file=" argument, you define an empty drive". As a
result the first vm I tried to start came back
with a message saying it could not open the diskfile.
Additionally, check below screenshot; the vm names appear to be missing.
Here's the complete XML of one vm,
did anything change coming from this one?
<domain type='kvm'>
<name>vm1</name>
<uuid>ea14abdc-12a4-48cb-1424-46cdf15405f4</uuid>
<memory>524288</memory>
<currentMemory>524288</currentMemory>
<vcpu>1</vcpu>
<os>
<type arch='x86_64' machine='pc'>hvm</type>
<boot dev='hd'/>
</os>
<features>
<acpi/>
<apic/>
<pae/>
</features>
<clock offset='utc'/>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>restart</on_crash>
<devices>
<emulator>/usr/bin/kvm</emulator>
<disk type='file' device='disk'>
<source file='/kvmimages/vm1.qcow2'/>
<target dev='vda' bus='virtio'/>
</disk>
<interface type='bridge'>
<mac address='54:52:00:0a:dc:10'/>
<source bridge='br0'/>
<model type='virtio'/>
</interface>
<serial type='pty'>
<source path='/dev/pts/1'/>
<target port='0'/>
</serial>
<console type='pty' tty='/dev/pts/1'>
<source path='/dev/pts/1'/>
<target port='0'/>
</console>
<input type='mouse' bus='ps2'/>
<graphics type='vnc' port='-1' autoport='yes' keymap='en-us'/>
</devices>
</domain>
15 years, 1 month
[libvirt] [PATCH] Maintain value of ctxt->node in virInterfaceDefParseDhcp.
by Laine Stump
This was causing subsequent calls to virXPathxxx() to fail, since
ctxt->node was left pointing at the dhcp node, rather than the
protocol node. Previously this had gone unnoticed, as the dhcp node
was the only thing parsed under ip, if it was there.
---
src/conf/interface_conf.c | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/src/conf/interface_conf.c b/src/conf/interface_conf.c
index 632f28f..818cff2 100644
--- a/src/conf/interface_conf.c
+++ b/src/conf/interface_conf.c
@@ -229,10 +229,12 @@ virInterfaceDefParseBondArpValid(virConnectPtr conn, xmlXPathContextPtr ctxt) {
static int
virInterfaceDefParseDhcp(virConnectPtr conn, virInterfaceDefPtr def,
xmlNodePtr dhcp, xmlXPathContextPtr ctxt) {
+ xmlNodePtr save;
char *tmp;
int ret = 0;
def->proto.dhcp = 1;
+ save = ctxt->node;
ctxt->node = dhcp;
/* Not much to do in the current version */
tmp = virXPathString(conn, "string(./@peerdns)", ctxt);
@@ -250,6 +252,7 @@ virInterfaceDefParseDhcp(virConnectPtr conn, virInterfaceDefPtr def,
} else
def->proto.peerdns = -1;
+ ctxt->node = save;
return(ret);
}
--
1.6.2.5
15 years, 1 month
[libvirt] [PATCH] Fix API doc extractor to stop munging comment formatting
by Daniel P. Berrange
The python method help docs are copied across from the C
funtion comments, but in the process all line breaks and
indentation was being lost. This made the resulting text
and code examples completely unreadable. Both the API
doc extractor and the python generator were destroying
whitespace & this fixes them to preserve it exactly.
* docs/apibuild.py: Preserve all whitespace when extracting
function comments. Print function comment inside a <![CDATA[
section to fully preserve all whitespace. Look for the
word 'returns' to describe return values, instead of 'return'
to avoid getting confused with code examples including the
C 'return' statement.
* python/generator.py: Preserve all whitespace when printing
function help docs
* src/libvirt.c: Change any return parameter indicated by
'return' to be 'returns', to avoid confusing the API extractor
---
docs/apibuild.py | 31 +++++++++++++++++++---------
python/generator.py | 25 ++++++++++++-----------
src/libvirt.c | 54 +++++++++++++++++++++++++-------------------------
3 files changed, 61 insertions(+), 49 deletions(-)
diff --git a/docs/apibuild.py b/docs/apibuild.py
index 855569b..70a7efc 100755
--- a/docs/apibuild.py
+++ b/docs/apibuild.py
@@ -838,14 +838,20 @@ class CParser:
arg, name))
while len(lines) > 0 and lines[0] == '*':
del lines[0]
- desc = ""
+ desc = None
while len(lines) > 0:
l = lines[0]
- while len(l) > 0 and l[0] == '*':
- l = l[1:]
- l = string.strip(l)
- if len(l) >= 6 and l[0:6] == "return" or l[0:6] == "Return":
- try:
+ i = 0
+ # Remove all leading '*', followed by at most one ' ' character
+ # since we need to preserve correct identation of code examples
+ while i < len(l) and l[i] == '*':
+ i = i + 1
+ if i > 0:
+ if i < len(l) and l[i] == ' ':
+ i = i + 1
+ l = l[i:]
+ if len(l) >= 6 and l[0:7] == "returns" or l[0:7] == "Returns":
+ try:
l = string.split(l, ' ', 1)[1]
except:
l = ""
@@ -859,9 +865,14 @@ class CParser:
retdesc = retdesc + " " + l
del lines[0]
else:
- desc = desc + " " + l
+ if desc is not None:
+ desc = desc + "\n" + l
+ else:
+ desc = l
del lines[0]
+ if desc is None:
+ desc = ""
retdesc = string.strip(retdesc)
desc = string.strip(desc)
@@ -1716,7 +1727,7 @@ class docBuilder:
try:
(args, desc) = id.info
if desc != None and desc != "":
- output.write(" <info>%s</info>\n" % (escape(desc)))
+ output.write(" <info><![CDATA[%s]]></info>\n" % (desc))
self.indexString(name, desc)
for arg in args:
(name, desc) = arg
@@ -1760,7 +1771,7 @@ class docBuilder:
try:
desc = id.extra
if desc != None and desc != "":
- output.write(">\n <info>%s</info>\n" % (escape(desc)))
+ output.write(">\n <info><![CDATA[%s]]></info>\n" % (desc))
output.write(" </typedef>\n")
else:
output.write("/>\n")
@@ -1796,7 +1807,7 @@ class docBuilder:
output.write(" <cond>%s</cond>\n"% (apstr));
try:
(ret, params, desc) = id.info
- output.write(" <info>%s</info>\n" % (escape(desc)))
+ output.write(" <info><![CDATA[%s]]></info>\n" % (desc))
self.indexString(name, desc)
if ret[0] != None:
if ret[0] == "void":
diff --git a/python/generator.py b/python/generator.py
index c34cb34..178a415 100755
--- a/python/generator.py
+++ b/python/generator.py
@@ -44,6 +44,7 @@ if sgmlop:
self.finish_starttag = target.start
self.finish_endtag = target.end
self.handle_data = target.data
+ self.handle_cdata = target.cdata
# activate parser
self.parser = sgmlop.XMLParser()
@@ -78,6 +79,7 @@ class SlowParser(xmllib.XMLParser):
def __init__(self, target):
self.unknown_starttag = target.start
self.handle_data = target.data
+ self.handle_cdata = target.cdata
self.unknown_endtag = target.end
xmllib.XMLParser.__init__(self)
@@ -108,6 +110,11 @@ class docParser:
print "data %s" % text
self._data.append(text)
+ def cdata(self, text):
+ if debug:
+ print "data %s" % text
+ self._data.append(text)
+
def start(self, tag, attrs):
if debug:
print "start %s, %s" % (tag, attrs)
@@ -843,20 +850,14 @@ def writeDoc(name, args, indent, output):
val = string.replace(val, "NULL", "None");
output.write(indent)
output.write('"""')
- while len(val) > 60:
- if val[0] == " ":
- val = val[1:]
- continue
- str = val[0:60]
- i = string.rfind(str, " ");
- if i < 0:
- i = 60
- str = val[0:i]
- val = val[i:]
+ i = string.find(val, "\n")
+ while i >= 0:
+ str = val[0:i+1]
+ val = val[i+1:]
output.write(str)
- output.write('\n ');
+ i = string.find(val, "\n")
output.write(indent)
- output.write(val);
+ output.write(val)
output.write(' """\n')
def buildWrappers():
diff --git a/src/libvirt.c b/src/libvirt.c
index 441f308..9d4d94b 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -818,7 +818,7 @@ virRegisterStateDriver(virStateDriverPtr driver)
*
* Initialize all virtualization drivers.
*
- * Return 0 if all succeed, -1 upon any failure.
+ * Returns 0 if all succeed, -1 upon any failure.
*/
int virStateInitialize(int privileged) {
int i, ret = 0;
@@ -839,7 +839,7 @@ int virStateInitialize(int privileged) {
*
* Run each virtualization driver's cleanup method.
*
- * Return 0 if all succeed, -1 upon any failure.
+ * Returns 0 if all succeed, -1 upon any failure.
*/
int virStateCleanup(void) {
int i, ret = 0;
@@ -857,7 +857,7 @@ int virStateCleanup(void) {
*
* Run each virtualization driver's reload method.
*
- * Return 0 if all succeed, -1 upon any failure.
+ * Returns 0 if all succeed, -1 upon any failure.
*/
int virStateReload(void) {
int i, ret = 0;
@@ -875,7 +875,7 @@ int virStateReload(void) {
*
* Run each virtualization driver's "active" method.
*
- * Return 0 if none are active, 1 if at least one is.
+ * Returns 0 if none are active, 1 if at least one is.
*/
int virStateActive(void) {
int i, ret = 0;
@@ -7044,7 +7044,7 @@ virStoragePoolRef(virStoragePoolPtr pool)
* involve communicating with a remote server, and/or initializing
* new devices at the OS layer
*
- * Return 0 if the volume list was refreshed, -1 on failure
+ * Returns 0 if the volume list was refreshed, -1 on failure
*/
int
virStoragePoolRefresh(virStoragePoolPtr pool,
@@ -7089,7 +7089,7 @@ error:
*
* Fetch the locally unique name of the storage pool
*
- * Return the name of the pool, or NULL on error
+ * Returns the name of the pool, or NULL on error
*/
const char*
virStoragePoolGetName(virStoragePoolPtr pool)
@@ -7113,7 +7113,7 @@ virStoragePoolGetName(virStoragePoolPtr pool)
*
* Fetch the globally unique ID of the storage pool
*
- * Return 0 on success, or -1 on error;
+ * Returns 0 on success, or -1 on error;
*/
int
virStoragePoolGetUUID(virStoragePoolPtr pool,
@@ -7149,7 +7149,7 @@ error:
*
* Fetch the globally unique ID of the storage pool as a string
*
- * Return 0 on success, or -1 on error;
+ * Returns 0 on success, or -1 on error;
*/
int
virStoragePoolGetUUIDString(virStoragePoolPtr pool,
@@ -7190,7 +7190,7 @@ error:
* Get volatile information about the storage pool
* such as free space / usage summary
*
- * returns 0 on success, or -1 on failure.
+ * Returns 0 on success, or -1 on failure.
*/
int
virStoragePoolGetInfo(virStoragePoolPtr pool,
@@ -7240,7 +7240,7 @@ error:
* storage pool. This is suitable for later feeding back
* into the virStoragePoolCreateXML method.
*
- * returns a XML document, or NULL on error
+ * Returns a XML document, or NULL on error
*/
char *
virStoragePoolGetXMLDesc(virStoragePoolPtr pool,
@@ -7287,7 +7287,7 @@ error:
* Fetches the value of the autostart flag, which determines
* whether the pool is automatically started at boot time
*
- * return 0 on success, -1 on failure
+ * Returns 0 on success, -1 on failure
*/
int
virStoragePoolGetAutostart(virStoragePoolPtr pool,
@@ -7333,7 +7333,7 @@ error:
*
* Sets the autostart flag
*
- * returns 0 on success, -1 on failure
+ * Returns 0 on success, -1 on failure
*/
int
virStoragePoolSetAutostart(virStoragePoolPtr pool,
@@ -7494,7 +7494,7 @@ virStorageVolGetConnect (virStorageVolPtr vol)
* Fetch a pointer to a storage volume based on its name
* within a pool
*
- * return a storage volume, or NULL if not found / error
+ * Returns a storage volume, or NULL if not found / error
*/
virStorageVolPtr
virStorageVolLookupByName(virStoragePoolPtr pool,
@@ -7539,7 +7539,7 @@ error:
* Fetch a pointer to a storage volume based on its
* globally unique key
*
- * return a storage volume, or NULL if not found / error
+ * Returns a storage volume, or NULL if not found / error
*/
virStorageVolPtr
virStorageVolLookupByKey(virConnectPtr conn,
@@ -7582,7 +7582,7 @@ error:
* Fetch a pointer to a storage volume based on its
* locally (host) unique path
*
- * return a storage volume, or NULL if not found / error
+ * Returns a storage volume, or NULL if not found / error
*/
virStorageVolPtr
virStorageVolLookupByPath(virConnectPtr conn,
@@ -7625,7 +7625,7 @@ error:
* Fetch the storage volume name. This is unique
* within the scope of a pool
*
- * return the volume name, or NULL on error
+ * Returns the volume name, or NULL on error
*/
const char*
virStorageVolGetName(virStorageVolPtr vol)
@@ -7650,7 +7650,7 @@ virStorageVolGetName(virStorageVolPtr vol)
* unique, so the same volume will have the same
* key no matter what host it is accessed from
*
- * return the volume key, or NULL on error
+ * Returns the volume key, or NULL on error
*/
const char*
virStorageVolGetKey(virStorageVolPtr vol)
@@ -7677,7 +7677,7 @@ virStorageVolGetKey(virStorageVolPtr vol)
* on an XML description. Not all pools support
* creation of volumes
*
- * return the storage volume, or NULL on error
+ * Returns the storage volume, or NULL on error
*/
virStorageVolPtr
virStorageVolCreateXML(virStoragePoolPtr pool,
@@ -7727,7 +7727,7 @@ error:
* volume (name, perms) are passed via a typical volume
* XML description.
*
- * return the storage volume, or NULL on error
+ * Returns the storage volume, or NULL on error
*/
virStorageVolPtr
virStorageVolCreateXMLFrom(virStoragePoolPtr pool,
@@ -7781,7 +7781,7 @@ error:
*
* Delete the storage volume from the pool
*
- * Return 0 on success, or -1 on error
+ * Returns 0 on success, or -1 on error
*/
int
virStorageVolDelete(virStorageVolPtr vol,
@@ -7827,7 +7827,7 @@ error:
* Release the storage volume handle. The underlying
* storage volume continues to exist.
*
- * Return 0 on success, or -1 on error
+ * Returns 0 on success, or -1 on error
*/
int
virStorageVolFree(virStorageVolPtr vol)
@@ -7885,7 +7885,7 @@ virStorageVolRef(virStorageVolPtr vol)
* Fetches volatile information about the storage
* volume such as its current allocation
*
- * Return 0 on success, or -1 on failure
+ * Returns 0 on success, or -1 on failure
*/
int
virStorageVolGetInfo(virStorageVolPtr vol,
@@ -7934,7 +7934,7 @@ error:
* Fetch an XML document describing all aspects of
* the storage volume
*
- * Return the XML document, or NULL on error
+ * Returns the XML document, or NULL on error
*/
char *
virStorageVolGetXMLDesc(virStorageVolPtr vol,
@@ -8165,7 +8165,7 @@ error:
* Fetch an XML document describing all aspects of
* the device.
*
- * Return the XML document, or NULL on error
+ * Returns the XML document, or NULL on error
*/
char *virNodeDeviceGetXMLDesc(virNodeDevicePtr dev, unsigned int flags)
{
@@ -9381,7 +9381,7 @@ virSecretRef(virSecretPtr secret)
*
* Release the secret handle. The underlying secret continues to exist.
*
- * Return 0 on success, or -1 on error
+ * Returns 0 on success, or -1 on error
*/
int
virSecretFree(virSecretPtr secret)
@@ -9852,7 +9852,7 @@ cleanup:
* used in conjunction with non-blocking data streams
* to integrate into an event loop
*
- * Return 0 on success, -1 upon error
+ * Returns 0 on success, -1 upon error
*/
int virStreamEventAddCallback(virStreamPtr stream,
int events,
@@ -9934,7 +9934,7 @@ error:
*
* Remove a event callback from the stream
*
- * Return 0 on success, -1 on error
+ * Returns 0 on success, -1 on error
*/
int virStreamEventRemoveCallback(virStreamPtr stream)
{
--
1.6.2.5
15 years, 1 month
[libvirt] Refactor libvirt spec file
by Daniel P. Berrange
The following patch refactors the libvirt spec file conditional
logic to make it a little easier to manage all the different
Fedora/RHEL OS build variations, and also allow for easy
creation of a client-only build
The patch follows, but I'm including the full specfile below
too, since its easier to understand than the diff
# -*- rpm-spec -*-
# A client only build will create a libvirt.so only containing
# the generic RPC driver, and test driver and no libvirtd
# Default to a full server + client build
%define client_only 0
# Now turn off server build in certain cases
# RHEL-5 builds are client-only for s390, ppc
%if 0%{?rhel} == 5
%ifnarch i386 i586 i686 x86_64 ia64
%define client_only 1
%endif
%endif
# Disable all server side drivers if client only build requested
%if %{client_only}
%define server_drivers 0
%else
%define server_drivers 1
%endif
# Now set the defaults for all the important features, independant
# of any particular OS
# First the daemon itself
%define with_libvirtd 0%{!?_without_libvirtd:%{server_drivers}}
%define with_avahi 0%{!?_without_avahi:%{server_drivers}}
# Then the hypervisor drivers
%define with_xen 0%{!?_without_xen:%{server_drivers}}
%define with_xen_proxy 0%{!?_without_xen_proxy:%{server_drivers}}
%define with_qemu 0%{!?_without_qemu:%{server_drivers}}
%define with_openvz 0%{!?_without_openvz:%{server_drivers}}
%define with_lxc 0%{!?_without_lxc:%{server_drivers}}
%define with_vbox 0%{!?_without_vbox:%{server_drivers}}
%define with_uml 0%{!?_without_uml:%{server_drivers}}
%define with_one 0%{!?_without_one:%{server_drivers}}
%define with_phyp 0%{!?_without_phyp:%{server_drivers}}
%define with_esx 0%{!?_without_esx:%{server_drivers}}
# Then the secondary host drivers
%define with_network 0%{!?_without_network:%{server_drivers}}
%define with_storage_fs 0%{!?_without_storage_fs:%{server_drivers}}
%define with_storage_lvm 0%{!?_without_storage_lvm:%{server_drivers}}
%define with_storage_iscsi 0%{!?_without_storage_iscsi:%{server_drivers}}
%define with_storage_disk 0%{!?_without_storage_disk:%{server_drivers}}
%define with_storage_mpath 0%{!?_without_storage_mpath:%{server_drivers}}
%define with_numactl 0%{!?_without_numactl:%{server_drivers}}
%define with_selinux 0%{!?_without_selinux:%{server_drivers}}
%define with_hal 0%{!?_without_hal:%{server_drivers}}
# A few optional bits off by default, we enable later
%define with_polkit 0%{!?_without_polkit:0}
%define with_capng 0%{!?_without_capng:0}
%define with_netcf 0%{!?_without_netcf:0}
# Non-server/HV driver defaults which are always enabled
%define with_python 0%{!?_without_python:1}
%define with_sasl 0%{!?_without_sasl:1}
# Finally set the OS / architecture specific special cases
# Xen is available only on i386 x86_64 ia64
%ifnarch i386 i586 i686 x86_64 ia64
%define with_xen 0
%endif
# RHEL doesn't ship OpenVZ, VBox, UML, OpenNebula, PowerHypervisor or ESX
%if 0%{?rhel}
%define with_openvz 0
%define with_vbox 0
%define with_uml 0
%define with_one 0
%define with_phyp 0
%define with_esx 0
%endif
# RHEL-5 has restricted QEMU to x86_64 only and is too old for LXC
%if 0%{?rhel} == 5
%ifnarch x86_64
%define with_qemu 0
%endif
%define with_lxc 0
%endif
# RHEL-6 has restricted QEMU to x86_64 only, stopped including Xen
# on all archs. Other archs all have LXC available though
%if 0%{?rhel} >= 6
%ifnarch x86_64
%define with_qemu 0
%endif
%define with_xen 0
%endif
# If Xen isn't turned on, we shouldn't build the xen proxy either
%if ! %{with_xen}
%define with_xen_proxy 0
%endif
# Fedora doesn't have any QEMU on ppc64 - only ppc
%if 0%{?fedora}
%ifarch ppc64
%define with_qemu 0
%endif
%endif
# PolicyKit was introduced in Fedora 8 / RHEL-6 or newer, allowing
# the setuid Xen proxy to be killed off
%if 0%{?fedora} >= 8 || 0%{?rhel} >= 6
%define with_polkit 0%{!?_without_polkit:1}
%define with_xen_proxy 0
%endif
# libcapng is used to manage capabilities in Fedora 12 / RHEL-6 or newer
%if 0%{?fedora} >= 12 || 0%{?rhel} >= 6
%define with_capng 0%{!?_without_capng:1}
%endif
# netcf is used to manage network interfaces in Fedora 12 / RHEL-6 or newer
%if 0%{?fedora} >= 12 || 0%{?rhel} >= 6
%define with_netcf 0%{!?_without_netcf:%{server_drivers}}
%endif
# Force QEMU to run as non-root
%if 0%{?fedora} >= 12 || 0%{?rhel} >= 6
%define qemu_user qemu
%define qemu_group qemu
%else
%define qemu_user root
%define qemu_group root
%endif
# The RHEL-5 Xen package has some feature backports. This
# flag is set to enable use of those special bits on RHEL-5
%if 0%{?rhel} == 5
%define with_rhel5 1
%else
%define with_rhel5 0
%endif
Summary: Library providing a simple API virtualization
Name: libvirt
Version: 0.7.1
Release: 1%{?dist}%{?extra_release}
License: LGPLv2+
Group: Development/Libraries
Source: http://libvirt.org/sources/libvirt-%{version}.tar.gz
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
URL: http://libvirt.org/
BuildRequires: python-devel
# The client side, i.e. shared libs and virsh are in a subpackage
Requires: libvirt-client = %{version}-%{release}
# Used by many of the drivers, so turn it on whenever the
# daemon is present
%if %{with_libvirtd}
Requires: bridge-utils
%endif
%if %{with_network}
Requires: dnsmasq
Requires: iptables
%endif
# needed for device enumeration
%if %{with_hal}
Requires: hal
%endif
%if %{with_polkit}
%if 0%{?fedora} >= 12 || 0%{?rhel} >=6
Requires: polkit >= 0.93
%else
Requires: PolicyKit >= 0.6
%endif
%endif
%if %{with_storage_fs}
# For mount/umount in FS driver
BuildRequires: util-linux
# For showmount in FS driver (netfs discovery)
BuildRequires: nfs-utils
Requires: nfs-utils
# For glusterfs
%if 0%{?fedora} >= 11
Requires: glusterfs-client >= 2.0.1
%endif
%endif
%if %{with_qemu}
# From QEMU RPMs
Requires: /usr/bin/qemu-img
# For image compression
Requires: gzip
Requires: bzip2
Requires: lzop
Requires: xz
%else
%if %{with_xen}
# From Xen RPMs
Requires: /usr/sbin/qcow-create
%endif
%endif
%if %{with_storage_lvm}
# For LVM drivers
Requires: lvm2
%endif
%if %{with_storage_iscsi}
# For ISCSI driver
Requires: iscsi-initiator-utils
%endif
%if %{with_storage_disk}
# For disk driver
Requires: parted
%endif
%if %{with_storage_mpath}
# For multipath support
Requires: device-mapper
%endif
%if %{with_xen}
BuildRequires: xen-devel
%endif
%if %{with_one}
BuildRequires: xmlrpc-c-devel >= 1.14.0
%endif
BuildRequires: libxml2-devel
BuildRequires: xhtml1-dtds
BuildRequires: readline-devel
BuildRequires: ncurses-devel
BuildRequires: gettext
BuildRequires: gnutls-devel
%if %{with_hal}
BuildRequires: hal-devel
%endif
%if %{with_avahi}
BuildRequires: avahi-devel
%endif
%if %{with_selinux}
BuildRequires: libselinux-devel
%endif
%if %{with_network}
BuildRequires: dnsmasq
%endif
BuildRequires: bridge-utils
%if %{with_sasl}
BuildRequires: cyrus-sasl-devel
%endif
%if %{with_polkit}
%if 0%{?fedora} >= 12 || 0%{?rhel} >= 6
# Only need the binary, not -devel
BuildRequires: polkit >= 0.93
%else
BuildRequires: PolicyKit-devel >= 0.6
%endif
%endif
%if %{with_storage_fs}
# For mount/umount in FS driver
BuildRequires: util-linux
%endif
%if %{with_qemu}
# From QEMU RPMs
BuildRequires: /usr/bin/qemu-img
%else
%if %{with_xen}
# From Xen RPMs
BuildRequires: /usr/sbin/qcow-create
%endif
%endif
%if %{with_storage_lvm}
# For LVM drivers
BuildRequires: lvm2
%endif
%if %{with_storage_iscsi}
# For ISCSI driver
BuildRequires: iscsi-initiator-utils
%endif
%if %{with_storage_disk}
# For disk driver
BuildRequires: parted-devel
%if 0%{?rhel} == 5
# Broken RHEL-5 parted RPM is missing a dep
BuildRequires: e2fsprogs-devel
%endif
%endif
%if %{with_storage_mpath}
# For Multipath support
%if 0%{?rhel} == 5
# Broken RHEL-5 packaging has header files in main RPM :-(
BuildRequires: device-mapper
%else
BuildRequires: device-mapper-devel
%endif
%endif
%if %{with_numactl}
# For QEMU/LXC numa info
BuildRequires: numactl-devel
%endif
%if %{with_capng}
BuildRequires: libcap-ng-devel >= 0.5.0
%endif
%if %{with_phyp}
BuildRequires: libssh2-devel
%endif
%if %{with_netcf}
BuildRequires: netcf-devel
%endif
# Fedora build root suckage
BuildRequires: gawk
%description
Libvirt is a C toolkit to interact with the virtualization capabilities
of recent versions of Linux (and other OSes). The main package includes
the libvirtd server exporting the virtualization support.
%package client
Summary: Client side library and utilities of the libvirt library
Group: Development/Libraries
Requires: readline
Requires: ncurses
# So remote clients can access libvirt over SSH tunnel
# (client invokes 'nc' against the UNIX socket on the server)
Requires: nc
%if %{with_sasl}
Requires: cyrus-sasl
# Not technically required, but makes 'out-of-box' config
# work correctly & doesn't have onerous dependencies
Requires: cyrus-sasl-md5
%endif
%description client
Shared libraries and client binaries needed to access to the
virtualization capabilities of recent versions of Linux (and other OSes).
%package devel
Summary: Libraries, includes, etc. to compile with the libvirt library
Group: Development/Libraries
Requires: libvirt = %{version}-%{release}
Requires: pkgconfig
%if %{with_xen}
Requires: xen-devel
%endif
%description devel
Includes and documentations for the C library providing an API to use
the virtualization capabilities of recent versions of Linux (and other OSes).
%if %{with_python}
%package python
Summary: Python bindings for the libvirt library
Group: Development/Libraries
Requires: libvirt = %{version}-%{release}
%description python
The libvirt-python package contains a module that permits applications
written in the Python programming language to use the interface
supplied by the libvirt library to use the virtualization capabilities
of recent versions of Linux (and other OSes).
%endif
%prep
%setup -q
%build
%if ! %{with_xen}
%define _without_xen --without-xen
%endif
%if ! %{with_qemu}
%define _without_qemu --without-qemu
%endif
%if ! %{with_openvz}
%define _without_openvz --without-openvz
%endif
%if ! %{with_lxc}
%define _without_lxc --without-lxc
%endif
%if ! %{with_vbox}
%define _without_vbox --without-vbox
%endif
%if ! %{with_sasl}
%define _without_sasl --without-sasl
%endif
%if ! %{with_avahi}
%define _without_avahi --without-avahi
%endif
%if ! %{with_phyp}
%define _without_phyp --without-phyp
%endif
%if ! %{with_esx}
%define _without_esx --without-esx
%endif
%if ! %{with_polkit}
%define _without_polkit --without-polkit
%endif
%if ! %{with_python}
%define _without_python --without-python
%endif
%if ! %{with_libvirtd}
%define _without_libvirtd --without-libvirtd
%endif
%if ! %{with_uml}
%define _without_uml --without-uml
%endif
%if ! %{with_one}
%define _without_one --without-one
%endif
%if %{with_rhel5}
%define _with_rhel5_api --with-rhel5-api
%endif
%if ! %{with_network}
%define _without_network --without-network
%endif
%if ! %{with_storage_fs}
%define _without_storage_fs --without-storage-fs
%endif
%if ! %{with_storage_lvm}
%define _without_storage_lvm --without-storage-lvm
%endif
%if ! %{with_storage_iscsi}
%define _without_storage_iscsi --without-storage-iscsi
%endif
%if ! %{with_storage_disk}
%define _without_storage_disk --without-storage-disk
%endif
%if ! %{with_storage_mpath}
%define _without_storage_mpath --without-storage-mpath
%endif
%if ! %{with_numactl}
%define _without_numactl --without-numactl
%endif
%if ! %{with_capng}
%define _without_capng --without-capng
%endif
%if ! %{with_netcf}
%define _without_netcf --without-netcf
%endif
%if ! %{with_selinux}
%define _without_selinux --without-selinux
%endif
%if ! %{with_hal}
%define _without_hal --without-hal
%endif
%configure %{?_without_xen} \
%{?_without_qemu} \
%{?_without_openvz} \
%{?_without_lxc} \
%{?_without_vbox} \
%{?_without_sasl} \
%{?_without_avahi} \
%{?_without_polkit} \
%{?_without_python} \
%{?_without_libvirtd} \
%{?_without_uml} \
%{?_without_one} \
%{?_without_phyp} \
%{?_without_esx} \
%{?_without_network} \
%{?_with_rhel5_api} \
%{?_without_storage_fs} \
%{?_without_storage_lvm} \
%{?_without_storage_iscsi} \
%{?_without_storage_disk} \
%{?_without_storage_mpath} \
%{?_without_numactl} \
%{?_without_capng} \
%{?_without_netcf} \
%{?_without_selinux} \
%{?_without_hal} \
--with-qemu-user=%{qemu_user} \
--with-qemu-group=%{qemu_group} \
--with-init-script=redhat \
--with-remote-pid-file=%{_localstatedir}/run/libvirtd.pid
make %{?_smp_mflags}
gzip -9 ChangeLog
%install
rm -fr %{buildroot}
%makeinstall
(cd docs/examples ; make clean ; rm -rf .deps Makefile Makefile.in)
(cd docs/examples/python ; rm -rf .deps Makefile Makefile.in)
(cd examples/hellolibvirt ; make clean ; rm -rf .deps .libs Makefile Makefile.in)
(cd examples/domain-events/events-c ; make clean ;rm -rf .deps .libs Makefile Makefile.in)
rm -f $RPM_BUILD_ROOT%{_libdir}/*.la
rm -f $RPM_BUILD_ROOT%{_libdir}/*.a
rm -f $RPM_BUILD_ROOT%{_libdir}/python*/site-packages/*.la
rm -f $RPM_BUILD_ROOT%{_libdir}/python*/site-packages/*.a
%if %{with_network}
# We don't want to install /etc/libvirt/qemu/networks in the main %files list
# because if the admin wants to delete the default network completely, we don't
# want to end up re-incarnating it on every RPM upgrade.
install -d -m 0755 $RPM_BUILD_ROOT%{_datadir}/libvirt/networks/
cp $RPM_BUILD_ROOT%{_sysconfdir}/libvirt/qemu/networks/default.xml \
$RPM_BUILD_ROOT%{_datadir}/libvirt/networks/default.xml
rm -f $RPM_BUILD_ROOT%{_sysconfdir}/libvirt/qemu/networks/default.xml
rm -f $RPM_BUILD_ROOT%{_sysconfdir}/libvirt/qemu/networks/autostart/default.xml
# Strip auto-generated UUID - we need it generated per-install
sed -i -e "/<uuid>/d" $RPM_BUILD_ROOT%{_datadir}/libvirt/networks/default.xml
%else
rm -f $RPM_BUILD_ROOT%{_sysconfdir}/libvirt/qemu/networks/default.xml
rm -f $RPM_BUILD_ROOT%{_sysconfdir}/libvirt/qemu/networks/autostart/default.xml
%endif
%if ! %{with_qemu}
rm -f $RPM_BUILD_ROOT%{_datadir}/augeas/lenses/libvirtd_qemu.aug
rm -f $RPM_BUILD_ROOT%{_datadir}/augeas/lenses/tests/test_libvirtd_qemu.aug
%endif
%find_lang %{name}
%if ! %{with_python}
rm -rf $RPM_BUILD_ROOT%{_datadir}/doc/libvirt-python-%{version}
%endif
%if %{client_only}
rm -rf $RPM_BUILD_ROOT%{_datadir}/doc/libvirt-%{version}
%endif
%if ! %{with_qemu}
rm -rf $RPM_BUILD_ROOT%{_sysconfdir}/libvirt/qemu.conf
%endif
%if %{with_libvirtd}
chmod 0644 $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig/libvirtd
%endif
%clean
rm -fr %{buildroot}
%pre
%if 0%{?fedora} >= 12 || 0%{?rhel} >= 6
# Normally 'setup' adds this in /etc/passwd, but this is
# here for case of upgrades from earlier Fedora/RHEL. This
# UID/GID pair is reserved for qemu:qemu
getent group kvm >/dev/null || groupadd -g 36 -r kvm
getent group qemu >/dev/null || groupadd -g 107 -r qemu
getent passwd qemu >/dev/null || \
useradd -r -u 107 -g qemu -G kvm -d / -s /sbin/nologin \
-c "qemu user" qemu
%endif
%post
%if %{with_libvirtd}
%if %{with_network}
# We want to install the default network for initial RPM installs
# or on the first upgrade from a non-network aware libvirt only.
# We check this by looking to see if the daemon is already installed
/sbin/chkconfig --list libvirtd 1>/dev/null 2>&1
if [ $? != 0 -a ! -f %{_sysconfdir}/libvirt/qemu/networks/default.xml ]
then
UUID=`/usr/bin/uuidgen`
sed -e "s,</name>,</name>\n <uuid>$UUID</uuid>," \
< %{_datadir}/libvirt/networks/default.xml \
> %{_sysconfdir}/libvirt/qemu/networks/default.xml
ln -s ../default.xml %{_sysconfdir}/libvirt/qemu/networks/autostart/default.xml
fi
%endif
/sbin/chkconfig --add libvirtd
if [ "$1" -ge "1" ]; then
/sbin/service libvirtd condrestart > /dev/null 2>&1
fi
%endif
%preun
%if %{with_libvirtd}
if [ $1 = 0 ]; then
/sbin/service libvirtd stop 1>/dev/null 2>&1
/sbin/chkconfig --del libvirtd
fi
%endif
%post client -p /sbin/ldconfig
%postun client -p /sbin/ldconfig
%if %{with_libvirtd}
%files
%defattr(-, root, root)
%doc AUTHORS ChangeLog.gz NEWS README COPYING.LIB TODO
%dir %attr(0700, root, root) %{_sysconfdir}/libvirt/
%if %{with_network}
%dir %attr(0700, root, root) %{_sysconfdir}/libvirt/qemu/
%dir %attr(0700, root, root) %{_sysconfdir}/libvirt/qemu/networks/
%dir %attr(0700, root, root) %{_sysconfdir}/libvirt/qemu/networks/autostart
%endif
%{_sysconfdir}/rc.d/init.d/libvirtd
%config(noreplace) %{_sysconfdir}/sysconfig/libvirtd
%config(noreplace) %{_sysconfdir}/libvirt/libvirtd.conf
%config(noreplace) %{_sysconfdir}/logrotate.d/libvirtd
%if %{with_qemu}
%config(noreplace) %{_sysconfdir}/libvirt/qemu.conf
%endif
%dir %{_datadir}/libvirt/
%if %{with_network}
%dir %{_datadir}/libvirt/networks/
%{_datadir}/libvirt/networks/default.xml
%endif
%dir %{_localstatedir}/run/libvirt/
%dir %{_localstatedir}/lib/libvirt/
%dir %attr(0711, root, root) %{_localstatedir}/lib/libvirt/images/
%dir %attr(0711, root, root) %{_localstatedir}/lib/libvirt/boot/
%dir %attr(0700, root, root) %{_localstatedir}/cache/libvirt/
%if %{with_qemu}
%dir %attr(0700, root, root) %{_localstatedir}/run/libvirt/qemu/
%dir %attr(0700, %{qemu_user}, %{qemu_group}) %{_localstatedir}/lib/libvirt/qemu/
%dir %attr(0700, %{qemu_user}, %{qemu_group}) %{_localstatedir}/cache/libvirt/qemu/
%endif
%if %{with_lxc}
%dir %{_localstatedir}/run/libvirt/lxc/
%dir %attr(0700, root, root) %{_localstatedir}/lib/libvirt/lxc/
%endif
%if %{with_uml}
%dir %{_localstatedir}/run/libvirt/uml/
%dir %attr(0700, root, root) %{_localstatedir}/lib/libvirt/uml/
%endif
%if %{with_network}
%dir %{_localstatedir}/run/libvirt/network/
%dir %attr(0700, root, root) %{_localstatedir}/lib/libvirt/network/
%dir %attr(0700, root, root) %{_localstatedir}/lib/libvirt/iptables/
%dir %attr(0700, root, root) %{_localstatedir}/lib/libvirt/iptables/filter/
%dir %attr(0700, root, root) %{_localstatedir}/lib/libvirt/iptables/nat/
%endif
%if %{with_qemu}
%{_datadir}/augeas/lenses/libvirtd_qemu.aug
%{_datadir}/augeas/lenses/tests/test_libvirtd_qemu.aug
%endif
%{_datadir}/augeas/lenses/libvirtd.aug
%{_datadir}/augeas/lenses/tests/test_libvirtd.aug
%if %{with_polkit}
%if 0%{?fedora} >= 12 || 0%{?rhel} >= 6
%{_datadir}/polkit-1/actions/org.libvirt.unix.policy
%else
%{_datadir}/PolicyKit/policy/org.libvirt.unix.policy
%endif
%endif
%dir %attr(0700, root, root) %{_localstatedir}/log/libvirt/
%if %{with_qemu}
%dir %attr(0700, root, root) %{_localstatedir}/log/libvirt/qemu/
%endif
%if %{with_xen_proxy}
%attr(4755, root, root) %{_libexecdir}/libvirt_proxy
%endif
%if %{with_lxc}
%attr(0755, root, root) %{_libexecdir}/libvirt_lxc
%endif
%attr(0755, root, root) %{_libexecdir}/libvirt_parthelper
%attr(0755, root, root) %{_sbindir}/libvirtd
%doc docs/*.xml
%endif
%files client -f %{name}.lang
%defattr(-, root, root)
%doc AUTHORS ChangeLog.gz NEWS README COPYING.LIB TODO
%{_mandir}/man1/virsh.1*
%{_mandir}/man1/virt-xml-validate.1*
%{_bindir}/virsh
%{_bindir}/virt-xml-validate
%{_libdir}/lib*.so.*
%dir %{_datadir}/libvirt/
%dir %{_datadir}/libvirt/schemas/
%{_datadir}/libvirt/schemas/domain.rng
%{_datadir}/libvirt/schemas/network.rng
%{_datadir}/libvirt/schemas/storagepool.rng
%{_datadir}/libvirt/schemas/storagevol.rng
%{_datadir}/libvirt/schemas/nodedev.rng
%{_datadir}/libvirt/schemas/capability.rng
%{_datadir}/libvirt/schemas/interface.rng
%{_datadir}/libvirt/schemas/secret.rng
%{_datadir}/libvirt/schemas/storageencryption.rng
%if %{with_sasl}
%config(noreplace) %{_sysconfdir}/sasl2/libvirt.conf
%endif
%files devel
%defattr(-, root, root)
%{_libdir}/lib*.so
%dir %{_includedir}/libvirt
%{_includedir}/libvirt/*.h
%{_libdir}/pkgconfig/libvirt.pc
%dir %{_datadir}/gtk-doc/html/libvirt/
%doc %{_datadir}/gtk-doc/html/libvirt/*.devhelp
%doc %{_datadir}/gtk-doc/html/libvirt/*.html
%doc %{_datadir}/gtk-doc/html/libvirt/*.png
%doc %{_datadir}/gtk-doc/html/libvirt/*.css
%doc docs/*.html docs/html docs/*.gif
%doc docs/examples
%doc docs/libvirt-api.xml
%doc examples
%if %{with_python}
%files python
%defattr(-, root, root)
%doc AUTHORS NEWS README COPYING.LIB
%{_libdir}/python*/site-packages/libvirt.py*
%{_libdir}/python*/site-packages/libvirtmod*
%doc python/tests/*.py
%doc python/TODO
%doc python/libvirtclass.txt
%doc docs/examples/python
%endif
15 years, 1 month