[libvirt] [php PATCH] Fix compiler warnings after int to long conversion
by Dawid Zamirski
The previous patch [1] caused compiler warnings after variable types
were changed from int to long and this patch fixes this.
[1] https://www.redhat.com/archives/libvir-list/2014-June/msg00835.html
---
src/libvirt-php.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/libvirt-php.c b/src/libvirt-php.c
index 224943d..6d6fa81 100644
--- a/src/libvirt-php.c
+++ b/src/libvirt-php.c
@@ -3928,7 +3928,7 @@ PHP_FUNCTION(libvirt_domain_send_pointer_event)
RETURN_FALSE;
}
- DPRINTF("%s: x = %d, y = %d, clicked = %d, release = %d, hostname = %s...\n", PHPFUNC, pos_x, pos_y, clicked, release, hostname);
+ DPRINTF("%s: x = %d, y = %d, clicked = %d, release = %d, hostname = %s...\n", PHPFUNC, (int) pos_x, (int) pos_y, (int) clicked, release, hostname);
ret = vnc_send_pointer_event(hostname, tmp, pos_x, pos_y, clicked, release);
if (ret == 0) {
DPRINTF("%s: Pointer event result is %d\n", PHPFUNC, ret);
@@ -4428,7 +4428,7 @@ PHP_FUNCTION(libvirt_domain_new)
numNets = i;
snprintf(tmpname, sizeof(tmpname), "%s-install", name);
- DPRINTF("%s: Name is '%s', memMB is %d, maxmemMB is %d\n", PHPFUNC, tmpname, memMB, maxmemMB);
+ DPRINTF("%s: Name is '%s', memMB is %d, maxmemMB is %d\n", PHPFUNC, tmpname, (int) memMB, (int) maxmemMB);
tmp = installation_get_xml(1,
conn->conn, tmpname, memMB, maxmemMB, NULL /* arch */, NULL, vcpus, iso_image,
vmDisks, numDisks, vmNetworks, numNets,
@@ -6272,7 +6272,7 @@ PHP_FUNCTION(libvirt_domain_snapshot_delete)
GET_SNAPSHOT_FROM_ARGS("r|l",&zsnapshot, &flags);
retval = virDomainSnapshotDelete(snapshot->snapshot, flags);
- DPRINTF("%s: virDomainSnapshotDelete(%p, %d) returned %d\n", PHPFUNC, snapshot->snapshot, flags, retval);
+ DPRINTF("%s: virDomainSnapshotDelete(%p, %d) returned %d\n", PHPFUNC, snapshot->snapshot, (int) flags, retval);
if (retval == -1) RETURN_FALSE;
RETURN_TRUE;
}
@@ -6772,7 +6772,7 @@ PHP_FUNCTION(libvirt_storagevolume_delete)
GET_VOLUME_FROM_ARGS("r|l",&zvolume,&flags);
retval = virStorageVolDelete(volume->volume, flags);
- DPRINTF("%s: virStorageVolDelete(%p, %d) returned %d\n", PHPFUNC, volume->volume, flags, retval);
+ DPRINTF("%s: virStorageVolDelete(%p, %d) returned %d\n", PHPFUNC, volume->volume, (int) flags, retval);
if (retval != 0) {
set_error_if_unset("Cannot delete storage volume" TSRMLS_CC);
RETURN_FALSE;
--
1.9.3
10 years, 5 months
[libvirt] [php PATCH] Use long variable type for zend_parse_parameters.
by Dawid Zamirski
This patch fixes a bug where zend_parse_parameters would segfault on
certain PHP version (spotted on PHP 5.3.2 64bit) where type specifier is
long "l" and variable reference is int or unsigned int. Changing the
variable type from int or unsigned int to long fixes the problem for me
and is a known issue [1]. This did not happen in newer PHP version
(5.3.10).
[1] https://bugs.php.net/bug.php?id=59289
---
src/libvirt-php.c | 32 ++++++++++++++++----------------
1 file changed, 16 insertions(+), 16 deletions(-)
diff --git a/src/libvirt-php.c b/src/libvirt-php.c
index 07ae137..224943d 100644
--- a/src/libvirt-php.c
+++ b/src/libvirt-php.c
@@ -3283,8 +3283,8 @@ PHP_FUNCTION(libvirt_domain_get_metadata)
{
php_libvirt_domain *domain = NULL;
zval *zdomain;
- int type = 0;
- unsigned int flags = 0;
+ long type = 0;
+ long flags = 0;
char *uri = NULL;
int uri_len;
char *ret = NULL;
@@ -3328,8 +3328,8 @@ PHP_FUNCTION(libvirt_domain_set_metadata)
char *metadata = NULL;
char *key = NULL;
char *uri = NULL;
- int type = 0;
- unsigned int flags = 0;
+ long type = 0;
+ long flags = 0;
int rc;
GET_DOMAIN_FROM_ARGS ("rlsssl", &zdomain, &type, &metadata, &metadata_len, &key, &key_len, &uri, &uri_len, &flags);
@@ -3566,7 +3566,7 @@ PHP_FUNCTION(libvirt_domain_get_screenshot_api)
{
php_libvirt_domain *domain=NULL;
zval *zdomain;
- unsigned int screen = 0;
+ long screen = 0;
int fd = -1;
char file[] = "/tmp/libvirt-php-tmp-XXXXXX";
virStreamPtr st = NULL;
@@ -3668,7 +3668,7 @@ PHP_FUNCTION(libvirt_domain_get_screenshot)
int port = -1;
char *hostname = NULL;
int hostname_len;
- int scancode = 10;
+ long scancode = 10;
char *path;
char name[1024] = { 0 };
int use_builtin = 0;
@@ -3908,9 +3908,9 @@ PHP_FUNCTION(libvirt_domain_send_pointer_event)
char *xml = NULL;
char *hostname = NULL;
int hostname_len;
- int pos_x = 0;
- int pos_y = 0;
- int clicked = 0;
+ long pos_x = 0;
+ long pos_y = 0;
+ long clicked = 0;
int release = 1;
int ret;
@@ -4352,12 +4352,12 @@ PHP_FUNCTION(libvirt_domain_new)
// char *emulator;
char *iso_image = NULL;
int iso_image_len;
- int vcpus = -1;
- int memMB = -1;
+ long vcpus = -1;
+ long memMB = -1;
zval *disks, *networks;
tVMDisk *vmDisks = NULL;
tVMNetwork *vmNetworks = NULL;
- int maxmemMB = -1;
+ long maxmemMB = -1;
HashTable *arr_hash;
int numDisks, numNets, i;
zval **data; // removed **zvalue
@@ -4642,7 +4642,7 @@ PHP_FUNCTION(libvirt_domain_get_interface_devices)
*/
PHP_FUNCTION(libvirt_domain_change_vcpus)
{
- int numCpus, flags = 0;
+ long numCpus, flags = 0;
php_libvirt_domain *domain=NULL;
zval *zdomain;
@@ -6266,7 +6266,7 @@ PHP_FUNCTION(libvirt_domain_snapshot_delete)
{
zval *zsnapshot;
php_libvirt_snapshot *snapshot;
- int flags = 0;
+ long flags = 0;
int retval;
GET_SNAPSHOT_FROM_ARGS("r|l",&zsnapshot, &flags);
@@ -6766,7 +6766,7 @@ PHP_FUNCTION(libvirt_storagevolume_delete)
{
php_libvirt_volume *volume=NULL;
zval *zvolume;
- int flags = 0;
+ long flags = 0;
int retval = 0;
GET_VOLUME_FROM_ARGS("r|l",&zvolume,&flags);
@@ -7057,7 +7057,7 @@ PHP_FUNCTION(libvirt_storagepool_refresh)
{
php_libvirt_storagepool *pool = NULL;
zval *zpool;
- unsigned long flags = 0;
+ long flags = 0;
int retval;
GET_STORAGEPOOL_FROM_ARGS ("r|l", &zpool, &flags);
--
1.9.3
10 years, 5 months
[libvirt] [PATCH] Valid pool format type for logical volume pool should be auto and lvm2
by Shanzhi Yu
The logical volume pool supports formats auto and lvm2
Signed-off-by: Shanzhi Yu <shyu(a)redhat.com>
---
src/conf/storage_conf.c | 2 +-
src/conf/storage_conf.h | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c
index 8b6fd79..3d61273 100644
--- a/src/conf/storage_conf.c
+++ b/src/conf/storage_conf.c
@@ -77,7 +77,7 @@ VIR_ENUM_IMPL(virStoragePoolFormatDisk,
VIR_ENUM_IMPL(virStoragePoolFormatLogical,
VIR_STORAGE_POOL_LOGICAL_LAST,
- "unknown", "lvm2")
+ "auto", "lvm2")
VIR_ENUM_IMPL(virStorageVolFormatDisk,
diff --git a/src/conf/storage_conf.h b/src/conf/storage_conf.h
index 04d99eb..2b08ac5 100644
--- a/src/conf/storage_conf.h
+++ b/src/conf/storage_conf.h
@@ -462,7 +462,7 @@ typedef enum {
VIR_ENUM_DECL(virStoragePoolFormatDisk)
typedef enum {
- VIR_STORAGE_POOL_LOGICAL_UNKNOWN = 0,
+ VIR_STORAGE_POOL_LOGICAL_AUTO = 0,
VIR_STORAGE_POOL_LOGICAL_LVM2 = 1,
VIR_STORAGE_POOL_LOGICAL_LAST,
} virStoragePoolFormatLogical;
--
1.9.3
10 years, 5 months
[libvirt] NL_RECV RETURNED WITH ERROR: NO BUFFER SPACE AVAILABLE ERROR FOR IXGBE LOAD
by vaughan
Hi experts,
Release: OL7
Kernel: 3.10.0-121.el7.x86_64
Noticed below error on OL7 server, while loading Intel 10gigabit nic
driver module , ixgbe in syslog
--------------------------------------------------------------------
journal: nl_recv returned with error: No buffer space available
-------------------------------------------------------------------
Complete syslog content for ixgbe module load :
un 16 20:46:10 ca-ostest432 kernel: ixgbe: Intel(R) 10 Gigabit PCI
Express Network Driver - version 3.15.1-k
Jun 16 20:46:10 ca-ostest432 kernel: ixgbe: Copyright (c) 1999-2013
Intel Corporation.
Jun 16 20:46:10 ca-ostest432 kvm: 1 guest now active
Jun 16 20:46:10 ca-ostest432 kvm: 0 guests now active
Jun 16 20:46:10 ca-ostest432 kernel: ixgbe 0000:13:00.0: Multiqueue
Enabled: Rx Queue count = 16, Tx Queue count = 16
Jun 16 20:46:10 ca-ostest432 kernel: ixgbe 0000:13:00.0: (PCI
Express:5.0GT/s:Width x8) 00:1b:21:c8:24:74
Jun 16 20:46:10 ca-ostest432 kernel: ixgbe 0000:13:00.0: MAC: 2, PHY: 9,
SFP+: 3, PBA No: E70856-007
Jun 16 20:46:10 ca-ostest432 kernel: ixgbe 0000:13:00.0: PCI Express
bandwidth of 32GT/s available
Jun 16 20:46:10 ca-ostest432 kernel: ixgbe 0000:13:00.0: (Speed:5.0GT/s,
Width: x8, Encoding Loss:20%)
Jun 16 20:46:10 ca-ostest432 journal: nl_recv returned with error: No
buffer space available
Jun 16 20:46:11 ca-ostest432 journal: nl_recv returned with error: No
buffer space available
Jun 16 20:46:11 ca-ostest432 systemd-udevd[4939]: renamed network
interface eth0 to ens2f0
Jun 16 20:46:11 ca-ostest432 kernel: ixgbe 0000:13:00.0: Intel(R) 10
Gigabit Network Connection
Jun 16 20:46:11 ca-ostest432 kernel: ixgbe 0000:13:00.1: Multiqueue
Enabled: Rx Queue count = 16, Tx Queue count = 16
Jun 16 20:46:11 ca-ostest432 kernel: ixgbe 0000:13:00.1: (PCI
Express:5.0GT/s:Width x8) 00:1b:21:c8:24:75
Jun 16 20:46:11 ca-ostest432 kernel: ixgbe 0000:13:00.1: MAC: 2, PHY: 9,
SFP+: 4, PBA No: E70856-007
Jun 16 20:46:11 ca-ostest432 kernel: ixgbe 0000:13:00.1: PCI Express
bandwidth of 32GT/s available
Jun 16 20:46:11 ca-ostest432 kernel: ixgbe 0000:13:00.1: (Speed:5.0GT/s,
Width: x8, Encoding Loss:20%)
Jun 16 20:46:11 ca-ostest432 systemd-udevd[4984]: renamed network
interface eth0 to ens2f1
Jun 16 20:46:11 ca-ostest432 kernel: ixgbe 0000:13:00.1: Intel(R) 10
Gigabit Network Connection
Jun 16 20:46:11 ca-ostest432 NetworkManager[1316]: <info> (ens2f0):
carrier is OFF (but ignored)
Jun 16 20:46:11 ca-ostest432 NetworkManager[1316]: <info> (ens2f0): new
Ethernet device (driver: 'ixgbe' ifindex: 14)
Jun 16 20:46:11 ca-ostest432 NetworkManager[1316]: <info> (ens2f0):
exported as /org/freedesktop/NetworkManager/Devices/13
Jun 16 20:46:11 ca-ostest432 NetworkManager[1316]: <info> (ens2f0):
device state change: unmanaged -> unavailable (reason 'managed') [10 20 2]
Jun 16 20:46:11 ca-ostest432 journal: nl_recv returned with error: No
buffer space available
Jun 16 20:46:11 ca-ostest432 kernel: ixgbe 0000:13:00.0: registered PHC
device on ens2f0
Jun 16 20:46:12 ca-ostest432 kernel: IPv6: ADDRCONF(NETDEV_UP): ens2f0:
link is not ready
Jun 16 20:46:12 ca-ostest432 NetworkManager[1316]: <info> (ens2f0):
preparing device
Jun 16 20:46:12 ca-ostest432 NetworkManager[1316]: <info> (ens2f1):
carrier is OFF (but ignored)
Jun 16 20:46:12 ca-ostest432 NetworkManager[1316]: <info> (ens2f1): new
Ethernet device (driver: 'ixgbe' ifindex: 15)
Jun 16 20:46:12 ca-ostest432 NetworkManager[1316]: <info> (ens2f1):
exported as /org/freedesktop/NetworkManager/Devices/14
Jun 16 20:46:12 ca-ostest432 NetworkManager[1316]: <info> (ens2f1):
device state change: unmanaged -> unavailable (reason 'managed') [10 20 2]
Jun 16 20:46:12 ca-ostest432 journal: nl_recv returned with error: No
buffer space available
Jun 16 20:46:12 ca-ostest432 NetworkManager[1316]: <info> (ens2f1):
preparing device
Jun 16 20:46:12 ca-ostest432 NetworkManager[1316]: <info> (ens2f0):
device state change: unavailable -> disconnected (reason 'none') [20 30 0]
Jun 16 20:46:12 ca-ostest432 NetworkManager[1316]: <info> (ens2f1):
device state change: unavailable -> disconnected (reason 'none') [20 30 0]
Jun 16 20:46:12 ca-ostest432 kernel: ixgbe 0000:13:00.0 ens2f0: detected
SFP+: 3
Jun 16 20:46:12 ca-ostest432 kernel: ixgbe 0000:13:00.1: registered PHC
device on ens2f1
Jun 16 20:46:12 ca-ostest432 kernel: IPv6: ADDRCONF(NETDEV_UP): ens2f1:
link is not ready
Jun 16 20:46:12 ca-ostest432 kernel: ixgbe 0000:13:00.1 ens2f1: detected
SFP+: 4
Jun 16 20:46:12 ca-ostest432 kernel: ixgbe 0000:13:00.1 ens2f1: NIC Link
is Up 10 Gbps, Flow Control: RX/TX
Jun 16 20:46:12 ca-ostest432 kernel: IPv6: ADDRCONF(NETDEV_CHANGE):
ens2f1: link becomes ready
Jun 16 20:46:12 ca-ostest432 NetworkManager[1316]: <info> (ens2f1): link
connected
Jun 16 20:46:12 ca-ostest432 kernel: ixgbe 0000:13:00.0 ens2f0: NIC Link
is Up 10 Gbps, Flow Control: RX/TX
Jun 16 20:46:12 ca-ostest432 kernel: IPv6: ADDRCONF(NETDEV_CHANGE):
ens2f0: link becomes ready
Jun 16 20:46:13 ca-ostest432 NetworkManager[1316]: <info> (ens2f0): link
connected
---------------------------------------------------------------------------------------------
Issue is not seen for other nic drivers when loaded , i.e verified with
be2net ,e1000e , igb drivers , so it looks like specific to ixgbe
driver module.
This problem can be addressed by increasing the size of the socket
receive buffer via nl_socket_set_buffer_size(). However, since reliable
transmissions from kernel to user are impossible in any case, I don't
know if we need to ensure enough buffer and how much it will be enough.
In my test, 32768*4 bytes of receive buffer size is ok. Below is my patch.
>From 4505e0001563bcef814dd2c6dc02b2d83e521867 Mon Sep 17 00:00:00 2001
From: rpm-build <rpm-build>
Date: Mon, 16 Jun 2014 20:05:08 +0800
Subject: [PATCH] set nl socket buffer size to 32768*4
Signed-off-by: Vaughan Cao <vaughan.cao(a)oracle.com>
---
src/util/virnetlink.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/src/util/virnetlink.c b/src/util/virnetlink.c
index 5849ed7..cf44ad2 100644
--- a/src/util/virnetlink.c
+++ b/src/util/virnetlink.c
@@ -561,6 +561,15 @@ virNetlinkEventServiceStart(unsigned int protocol,
unsigned int groups)
goto error_server;
}
+ if (nl_socket_set_buffer_size(srv->netlinknh, (32768*4), 0)) {
+ virReportSystemError(errno, "%s",
+ _("cannot set netlink socket buffer size to 32768*4"));
+ goto error_server;
+ } else {
+ virReportSystemError(0, "%s",
+ _("set netlink socket buffer size to 32768*4"));
+ }
+
if ((srv->eventwatch = virEventAddHandle(fd,
VIR_EVENT_HANDLE_READABLE,
virNetlinkEventCallback,
--
1.9.0
--
Regards,
Vaughan
10 years, 5 months
[libvirt] [PATCH 0/2] fix issues in vbox found by make check on RHEL6
by Pavel Hrdina
Pavel Hrdina (2):
tests: fix vbox snapshot xmls
vbox_snapshot_conf: fix wrong use of 'xmlSaveFormatFileEnc'
src/vbox/vbox_snapshot_conf.c | 2 +-
tests/vboxsnapshotxmldata/2disks-1snap.vbox | 292 +++----
tests/vboxsnapshotxmldata/2disks-2snap.vbox | 584 +++++++-------
.../vboxsnapshotxmldata/2disks-3snap-brother.vbox | 292 +++----
tests/vboxsnapshotxmldata/2disks-3snap.vbox | 876 ++++++++++-----------
5 files changed, 1023 insertions(+), 1023 deletions(-)
--
1.8.5.5
10 years, 5 months
[libvirt] [PATCH 00/12] Couple of host info getting improvements
by Michal Privoznik
The rationale is to fill in the gaps as described here:
https://wiki.openstack.org/wiki/VirtDriverGuestCPUMemoryPlacement
Note that these are targeted for 1.2.6.
Michal Privoznik (12):
Introduce virNodeHugeTLB
Initial virsh exposure of virNodeHugeTLB
nodeinfo: Implement nodeHugeTLB
virpci: Introduce virPCIDeviceIsPCIExpress and friends
nodedev: Introduce <pci-express/> to PCI devices
virInterface: Expose link state & speed
interface_backend_udev: Implement link speed & state
interface_backend_netcf: Implement link speed & state
virhostdev: Move IOMMU and VFIO funcs from qemu
virCaps: Introduce IOMMU and VFIO capabilities
Expose IOMMU and VFIO capabilities from virCaps
nodedev: Export NUMA node locality for PCI devices
daemon/remote.c | 54 ++++++
docs/formatcaps.html.in | 8 +-
docs/formatnode.html.in | 25 +++
docs/schemas/capability.rng | 12 ++
docs/schemas/interface.rng | 27 +++
docs/schemas/nodedev.rng | 37 ++++
include/libvirt/libvirt.h.in | 26 +++
src/conf/capabilities.c | 50 ++++++
src/conf/capabilities.h | 11 ++
src/conf/interface_conf.c | 39 ++++-
src/conf/interface_conf.h | 15 ++
src/conf/node_device_conf.c | 166 +++++++++++++++++-
src/conf/node_device_conf.h | 32 +++-
src/driver.h | 7 +
src/interface/interface_backend_netcf.c | 99 +++++++++++
src/interface/interface_backend_udev.c | 19 ++
src/libvirt.c | 59 +++++++
src/libvirt_private.syms | 13 ++
src/libvirt_public.syms | 5 +
src/lxc/lxc_conf.c | 3 +
src/node_device/node_device_udev.c | 38 ++++
src/nodeinfo.c | 192 +++++++++++++++++++++
src/nodeinfo.h | 6 +
src/parallels/parallels_driver.c | 3 +
src/phyp/phyp_driver.c | 3 +
src/qemu/qemu_capabilities.c | 3 +
src/qemu/qemu_driver.c | 30 +++-
src/qemu/qemu_hostdev.c | 93 ++--------
src/qemu/qemu_hostdev.h | 2 -
src/remote/remote_driver.c | 48 ++++++
src/remote/remote_protocol.x | 19 +-
src/remote_protocol-structs | 13 ++
src/uml/uml_conf.c | 3 +
src/util/virhostdev.c | 73 ++++++++
src/util/virhostdev.h | 4 +
src/util/virpci.c | 81 ++++++++-
src/util/virpci.h | 8 +
src/vbox/vbox_tmpl.c | 3 +
tests/capabilityschemadata/caps-qemu-kvm.xml | 2 +
tests/capabilityschemadata/caps-test.xml | 2 +
tests/capabilityschemadata/caps-test2.xml | 2 +
tests/capabilityschemadata/caps-test3.xml | 2 +
tests/interfaceschemadata/bridge-no-address.xml | 1 +
tests/interfaceschemadata/bridge.xml | 1 +
tests/interfaceschemadata/ethernet-dhcp.xml | 1 +
tests/nodedevschemadata/pci_1002_71c4.xml | 1 +
tests/nodedevschemadata/pci_8086_10c9_sriov_pf.xml | 1 +
.../pci_8086_4238_pcie_wireless.xml | 26 +++
tests/nodedevxml2xmltest.c | 1 +
tests/xencapsdata/xen-i686-pae-hvm.xml | 2 +
tests/xencapsdata/xen-i686-pae.xml | 2 +
tests/xencapsdata/xen-i686.xml | 2 +
tests/xencapsdata/xen-ia64-be-hvm.xml | 2 +
tests/xencapsdata/xen-ia64-be.xml | 2 +
tests/xencapsdata/xen-ia64-hvm.xml | 2 +
tests/xencapsdata/xen-ia64.xml | 2 +
tests/xencapsdata/xen-ppc64.xml | 2 +
tests/xencapsdata/xen-x86_64-hvm.xml | 2 +
tests/xencapsdata/xen-x86_64.xml | 2 +
tools/virsh-host.c | 62 +++++++
tools/virsh.pod | 7 +
61 files changed, 1371 insertions(+), 87 deletions(-)
create mode 100644 tests/nodedevschemadata/pci_8086_4238_pcie_wireless.xml
--
1.9.3
10 years, 5 months
Re: [libvirt] [PATCH v2 4/4] libxl: Add a test suite for libxl option generator
by Ian Campbell
On Mon, 2014-06-16 at 17:11 -0600, Jim Fehlig wrote:
> > This function exists in Xen 4.2 as well, in libxl.h.
> >
>
> Any ideas on how to handle this? I'm not aware of an existing macro to
> check for func 'foo' defined in header 'bar'. Is writing a custom macro
> along these lines a good solution? A bad solution I tried was hacking
> the test to check libxl version via libxl_get_version_info(), but that
> API does not work if not running Xen.
Given that it exists in everything from 4.2 onwards why do you need to
check for it?
>From the PoV of these tests (or any application generally) I'd have
thought you wouldn't really care if you get this function from libxl.h
directly or indirectly via libxl.h including _libxl_types.h.
Ian.
10 years, 5 months
[libvirt] [PATCH 1/1] virt-aa-helper: allow access to /dev/vhost-net if needed
by Serge Hallyn
Only allow the access if it is a KVM domain which has a NIC which wants
non-userspace networking.
This addresses https://bugs.launchpad.net/ubuntu/+source/libvirt/+bug/1322568
Signed-off-by: Serge Hallyn <serge.hallyn(a)ubuntu.com>
---
src/security/virt-aa-helper.c | 17 ++++++++++++++++-
1 file changed, 16 insertions(+), 1 deletion(-)
diff --git a/src/security/virt-aa-helper.c b/src/security/virt-aa-helper.c
index 1d246c7..e54f73f 100644
--- a/src/security/virt-aa-helper.c
+++ b/src/security/virt-aa-helper.c
@@ -929,7 +929,7 @@ get_files(vahControl * ctl)
size_t i;
char *uuid;
char uuidstr[VIR_UUID_STRING_BUFLEN];
- bool needsVfio = false;
+ bool needsVfio = false, needsvhost = false;
/* verify uuid is same as what we were given on the command line */
virUUIDFormat(ctl->def->uuid, uuidstr);
@@ -1105,6 +1105,21 @@ get_files(vahControl * ctl)
}
}
+ if (ctl->def->virtType == VIR_DOMAIN_VIRT_KVM) {
+ for (i = 0; i < ctl->def->nnets; i++) {
+ virDomainNetDefPtr net = ctl->def->nets[i];
+ if (net && net->model) {
+ if (net->driver.virtio.name == VIR_DOMAIN_NET_BACKEND_TYPE_QEMU)
+ continue;
+ if (STRNEQ(net->model, "virtio"))
+ continue;
+ }
+ needsvhost = true;
+ }
+ }
+ if (needsvhost)
+ virBufferAddLit(&buf, " /dev/vhost-net rw,\n");
+
if (needsVfio) {
virBufferAddLit(&buf, " /dev/vfio/vfio rw,\n");
virBufferAddLit(&buf, " /dev/vfio/[0-9]* rw,\n");
--
1.9.1
10 years, 5 months
[libvirt] [PATCH v3] Added example script on how to convert LXC container config
by Cédric Bosdonnat
---
Diff to v2:
* Added copyright + license header
* Fixed the nits
Makefile.am | 3 +-
configure.ac | 1 +
examples/lxcconvert/Makefile.am | 18 +++++
examples/lxcconvert/virt-lxc-convert | 127 +++++++++++++++++++++++++++++++++++
4 files changed, 148 insertions(+), 1 deletion(-)
create mode 100644 examples/lxcconvert/Makefile.am
create mode 100644 examples/lxcconvert/virt-lxc-convert
diff --git a/Makefile.am b/Makefile.am
index b961c0e..abc5a2f 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -23,7 +23,8 @@ SUBDIRS = . gnulib/lib include src daemon tools docs gnulib/tests \
tests po examples/object-events examples/hellolibvirt \
examples/dominfo examples/domsuspend examples/apparmor \
examples/xml/nwfilter examples/openauth examples/systemtap \
- tools/wireshark examples/dommigrate
+ tools/wireshark examples/dommigrate \
+ examples/lxcconvert
ACLOCAL_AMFLAGS = -I m4
diff --git a/configure.ac b/configure.ac
index 368d094..710cb71 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2742,6 +2742,7 @@ AC_CONFIG_FILES([\
examples/hellolibvirt/Makefile \
examples/systemtap/Makefile \
examples/xml/nwfilter/Makefile \
+ examples/lxcconvert/Makefile \
tools/wireshark/Makefile \
tools/wireshark/src/Makefile])
AC_OUTPUT
diff --git a/examples/lxcconvert/Makefile.am b/examples/lxcconvert/Makefile.am
new file mode 100644
index 0000000..09cf5d9
--- /dev/null
+++ b/examples/lxcconvert/Makefile.am
@@ -0,0 +1,18 @@
+## Copyright (C) 2014 SUSE LINUX Products GmbH, Nuernberg, Germany.
+##
+## This library is free software; you can redistribute it and/or
+## modify it under the terms of the GNU Lesser General Public
+## License as published by the Free Software Foundation; either
+## version 2.1 of the License, or (at your option) any later version.
+##
+## This library is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+## Lesser General Public License for more details.
+##
+## You should have received a copy of the GNU Lesser General Public
+## License along with this library. If not, see
+## <http://www.gnu.org/licenses/>.
+
+EXTRA_DIST= \
+ virt-lxc-convert
diff --git a/examples/lxcconvert/virt-lxc-convert b/examples/lxcconvert/virt-lxc-convert
new file mode 100644
index 0000000..7220153
--- /dev/null
+++ b/examples/lxcconvert/virt-lxc-convert
@@ -0,0 +1,127 @@
+#!/bin/sh
+# lxc_native.c: LXC native configuration import
+#
+# Copyright (c) 2014 SUSE LINUX Products GmbH, Nuernberg, Germany.
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library. If not, see
+# <http://www.gnu.org/licenses/>.
+#
+# Author: Cedric Bosdonnat <cbosdonnat(a)suse.com>
+
+handler_cleanup()
+{
+ if test "$conf_dir"; then
+ # Remove the temporary config
+ rm -r "$conf_dir"
+ fi
+}
+trap handler_cleanup INT EXIT
+
+show_help()
+{
+ cat << EOF
+$0 /path/to/lxc/config/file
+
+Wrapper around virsh domxml-from-native to ease conversion of LXC
+containers configuration to libvirt domain XML.
+EOF
+}
+
+if test $# != 1; then
+ show_help
+ exit 1
+fi
+
+if test "$1" = "--help" || test "$1" = "-h"; then
+ show_help
+ exit $?
+fi
+
+conf=$1
+
+conf_dir=$(mktemp --tmpdir -d virt-lxc-convert-XXX)
+conf_new=$conf_dir/config
+
+cp "$conf" "$conf_new"
+
+# Do we have lxc.mount, and is it pointing to a readable file?
+fstab=$(sed -n '/lxc.mount[[:space:]]*=/ s/[[:space:]]*=[[:space:]]*/=/p' \
+ "$conf_new" | cut -f 2 -d '=')
+if test -r "$fstab"; then
+ sed 's/^lxc.mount[[:space:]]*=.*$//' "$conf_new" >"${conf_new}.tmp"
+ mv "${conf_new}.tmp" "${conf_new}"
+ sed 's/^\([^#]\)/lxc.mount.entry = \1/' "$fstab" >>"${conf_new}"
+fi
+
+memory=$(free | sed -n '/Mem:/s/ \+/ /gp' | cut -f 2 -d ' ')
+default_tmpfs="size=$((memory/2))"
+
+# Do we have tmpfs without size param?
+lineno=0
+while read line; do
+ lineno=$(expr $lineno + 1)
+ has_rel_size=false
+ case $line in
+ lxc.mount.entry[[:space:]]*=[[:space:]]*tmpfs[[:space:]]*)
+ is_tmpfs=true
+ ;;
+ *)
+ is_tmpfs=false
+ ;;
+ esac
+
+ # We only care about tmpfs mount entries here
+ if ! $is_tmpfs; then
+ continue
+ fi
+
+ case $line in
+ *size=[0-9][0-9]*%*)
+ has_rel_size=true
+ has_size=true
+ ;;
+ *size=*)
+ has_size=true
+ ;;
+ *)
+ has_size=false
+ ;;
+ esac
+
+ # Add the default size here (50%) if no size is given
+ if ! $has_size; then
+ last_option_match="\([[:space:]]*[0-9][[:space:]]*[0-9][::space::]*$\)"
+ sed "${lineno}s/$last_option_match/,$default_tmpfs\1/" \
+ "$conf_new" >"${conf_new}.tmp"
+ mv "${conf_new}.tmp" "${conf_new}"
+ fi
+
+ # Convert relative sizes
+ if $has_rel_size; then
+ percent=$(echo "$line" | sed 's/.*size=\([0-9][0-9]*\)%.*/\1/')
+ size="$((memory*percent/100))"
+ sed "${lineno}s/size=[0-9]*%/size=${size}/" \
+ "$conf_new" >"${conf_new}.tmp"
+ mv "${conf_new}.tmp" "${conf_new}"
+ fi
+done < "$conf_new"
+
+# Do we have any memory limit set?
+mem_limit=$(grep 'lxc.cgroup.memory.limit_in_bytes[[:space:]]*=' $conf_new)
+if test -z "$mem_limit"; then
+ echo "lxc.cgroup.memory.limit_in_bytes = $memory" >> "$conf_new"
+fi
+
+virsh -c lxc:/// domxml-from-native lxc-tools $conf_new
+exit $?
--
1.8.4.5
10 years, 5 months