[libvirt] [PATCH] rpc: fix a virObject typo error in struct _virNetServer
by Guannan Ren
This typo will crash libvirtd when it recevies signal SIGINT
---
src/rpc/virnetserver.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/src/rpc/virnetserver.c b/src/rpc/virnetserver.c
index a1ea038..15abb56 100644
--- a/src/rpc/virnetserver.c
+++ b/src/rpc/virnetserver.c
@@ -64,7 +64,7 @@ struct _virNetServerJob {
};
struct _virNetServer {
- virObjectPtr object;
+ virObject object;
virMutex lock;
--
1.7.7.6
12 years, 3 months
[libvirt] [PATCH v6 0/6] file descriptor passing using fd sets
by Corey Bryant
libvirt's sVirt security driver provides SELinux MAC isolation for
Qemu guest processes and their corresponding image files. In other
words, sVirt uses SELinux to prevent a QEMU process from opening
files that do not belong to it.
sVirt provides this support by labeling guests and resources with
security labels that are stored in file system extended attributes.
Some file systems, such as NFS, do not support the extended
attribute security namespace, and therefore cannot support sVirt
isolation.
A solution to this problem is to provide fd passing support, where
libvirt opens files and passes file descriptors to QEMU. This,
along with SELinux policy to prevent QEMU from opening files, can
provide image file isolation for NFS files stored on the same NFS
mount.
This patch series adds the add-fd, remove-fd, and query-fdsets
QMP monitor commands, which allow file descriptors to be passed
via SCM_RIGHTS, and assigned to specified fd sets. This allows
fd sets to be created per file with fds having, for example,
different access rights. When QEMU needs to reopen a file with
different access rights, it can search for a matching fd in the
fd set. Fd sets also allow for easy tracking of fds per file,
helping to prevent fd leaks.
Support is also added to the block layer to allow QEMU to dup an
fd from an fdset when the filename is of the /dev/fdset/nnn format,
where nnn is the fd set ID.
No new SELinux policy is required to prevent open of NFS files
(files with type nfs_t). The virt_use_nfs boolean type simply
needs to be set to false, and open will be prevented (and dup will
be allowed). For example:
# setsebool virt_use_nfs 0
# getsebool virt_use_nfs
virt_use_nfs --> off
Corey Bryant (6):
qemu-char: Add MSG_CMSG_CLOEXEC flag to recvmsg
qapi: Introduce add-fd, remove-fd, query-fdsets
monitor: Clean up fd sets on monitor disconnect
block: Convert open calls to qemu_open
block: Convert close calls to qemu_close
block: Enable qemu_open/close to work with fd sets
block/raw-posix.c | 42 ++++----
block/raw-win32.c | 6 +-
block/vdi.c | 5 +-
block/vmdk.c | 25 ++---
block/vpc.c | 4 +-
block/vvfat.c | 16 +--
cutils.c | 5 +
monitor.c | 287 ++++++++++++++++++++++++++++++++++++++++++++++++++++-
monitor.h | 5 +
osdep.c | 117 ++++++++++++++++++++++
qapi-schema.json | 103 +++++++++++++++++++
qemu-char.c | 12 ++-
qemu-common.h | 2 +
qemu-tool.c | 21 ++++
qerror.c | 4 +
qerror.h | 3 +
qmp-commands.hx | 126 +++++++++++++++++++++++
savevm.c | 4 +-
18 files changed, 732 insertions(+), 55 deletions(-)
--
1.7.10.4
12 years, 3 months
[libvirt] [PATCH] qemu: Avoid libvirtd crash in qemuDomainObjExitAgentInternal
by Alex Jia
* src/qemu/qemu_domain.c (qemuDomainObjExitAgentInternal): fix crashing
libvirtd due to derefing a NULL pointer.
For details, please see bug:
RHBZ: https://bugzilla.redhat.com/show_bug.cgi?id=845966
Signed-off-by: Alex Jia <ajia(a)redhat.com>
---
src/qemu/qemu_domain.c | 10 ++++++----
1 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 86f0265..8667b6c 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -1136,12 +1136,14 @@ qemuDomainObjExitAgentInternal(struct qemud_driver *driver,
virDomainObjPtr obj)
{
qemuDomainObjPrivatePtr priv = obj->privateData;
- int refs;
+ int refs = -1;
- refs = qemuAgentUnref(priv->agent);
+ if (priv->agent) {
+ refs = qemuAgentUnref(priv->agent);
- if (refs > 0)
- qemuAgentUnlock(priv->agent);
+ if (refs > 0)
+ qemuAgentUnlock(priv->agent);
+ }
if (driver_locked)
qemuDriverLock(driver);
--
1.7.1
12 years, 3 months
[libvirt] [test-API][PATCH v2] Reconnct libvirt after libvirtd restart
by Wayne Sun
In domain_nfs_start case, libvirtd will be restarted during test,
which broke existing connection. User need re-init connection in
test case, for this:
* New get_conn function in utils for get libvirt connection
* sharemod_init in env_inspect use get_conn to get libvirt
connection
* In case domain_nfs_start, use get_conn to get new connectin
after libvirtd restarted.
Signed-off-by: Wayne Sun <gsun(a)redhat.com>
---
repos/sVirt/domain_nfs_start.py | 9 +++++++--
src/env_inspect.py | 22 ++--------------------
utils/utils.py | 29 ++++++++++++++++++++++++++++-
3 files changed, 37 insertions(+), 23 deletions(-)
diff --git a/repos/sVirt/domain_nfs_start.py b/repos/sVirt/domain_nfs_start.py
index 88d349c..5475945 100644
--- a/repos/sVirt/domain_nfs_start.py
+++ b/repos/sVirt/domain_nfs_start.py
@@ -12,7 +12,6 @@ import sys
import libvirt
from libvirt import libvirtError
-
from src import sharedmod
from utils import utils
from shutil import copy
@@ -163,6 +162,8 @@ def domain_nfs_start(params):
logger.error("Error: fail to get domain %s xml" % guestname)
return 1
+ conn.close()
+
# set env
logger.info("prepare the environment")
ret = prepare_env(dynamic_ownership, virt_use_nfs, guestname, \
@@ -171,6 +172,10 @@ def domain_nfs_start(params):
logger.error("failed to prepare the environment")
return 1
+ # reconnect libvirt
+ conn = utils.get_conn()
+ sharedmod.libvirtobj['conn'] = conn
+
domobj = conn.lookupByName(guestname)
logger.info("begin to test start domain from nfs storage")
@@ -283,7 +288,7 @@ def domain_nfs_start(params):
logger.error("Error: fail to get domain %s state" % guestname)
return 1
- if state != "shutoff":
+ if state != libvirt.VIR_DOMAIN_SHUTOFF:
logger.info("shut down the domain %s" % guestname)
try:
domobj.destroy()
diff --git a/src/env_inspect.py b/src/env_inspect.py
index b260ff8..2c1a701 100644
--- a/src/env_inspect.py
+++ b/src/env_inspect.py
@@ -20,6 +20,7 @@
import commands
import libvirt
import sharedmod
+from utils import utils
def check_libvirt(logger):
virsh = 'virsh -v'
@@ -68,20 +69,6 @@ def hostinfo(logger):
return 1
return 0
-def request_credentials(credentials, user_data):
- for credential in credentials:
- if credential[0] == libvirt.VIR_CRED_AUTHNAME:
- credential[4] = user_data[0]
-
- if len(credential[4]) == 0:
- credential[4] = credential[3]
- elif credential[0] == libvirt.VIR_CRED_PASSPHRASE:
- credential[4] = user_data[1]
- else:
- return -1
-
- return 0
-
def sharemod_init(env_parser, logger):
""" get connection object from libvirt module
initialize sharemod for use by testcases
@@ -89,12 +76,7 @@ def sharemod_init(env_parser, logger):
uri = env_parser.get_value('variables', 'defaulturi')
username = env_parser.get_value('variables', 'username')
password = env_parser.get_value('variables', 'password')
- user_data = [username, password]
- auth = [[libvirt.VIR_CRED_AUTHNAME, libvirt.VIR_CRED_PASSPHRASE], request_credentials, user_data]
- conn = libvirt.openAuth(uri, auth, 0)
- if not conn:
- logger.error("Failed to setup libvirt connection");
- return 1
+ conn = utils.get_conn(uri, username, password)
# initialize conn object in sharedmod
sharedmod.libvirtobj.clear()
diff --git a/utils/utils.py b/utils/utils.py
index be87cdc..9167c29 100644
--- a/utils/utils.py
+++ b/utils/utils.py
@@ -29,6 +29,7 @@ import struct
import pexpect
import string
import subprocess
+import libvirt
from xml.dom import minidom
from urlparse import urlparse
@@ -57,6 +58,32 @@ def get_uri(ip):
uri = "qemu+ssh://%s/system" % ip
return uri
+def request_credentials(credentials, user_data):
+ for credential in credentials:
+ if credential[0] == libvirt.VIR_CRED_AUTHNAME:
+ credential[4] = user_data[0]
+
+ if len(credential[4]) == 0:
+ credential[4] = credential[3]
+ elif credential[0] == libvirt.VIR_CRED_PASSPHRASE:
+ credential[4] = user_data[1]
+ else:
+ return -1
+
+ return 0
+
+def get_conn(uri=None, username='', password=''):
+ """ get connection object from libvirt module
+ """
+ user_data = [username, password]
+ auth = [[libvirt.VIR_CRED_AUTHNAME, libvirt.VIR_CRED_PASSPHRASE], request_credentials, user_data]
+ conn = libvirt.openAuth(uri, auth, 0)
+ if not conn:
+ logger.error("Failed to setup libvirt connection");
+ sys.exit(1)
+ else:
+ return conn
+
def parse_uri(uri):
# This is a simple parser for uri
return urlparse(uri)
@@ -501,7 +528,7 @@ def remote_exec_pexpect(hostname, username, password, cmd):
elif index == 1:
child.sendline(password)
elif index == 2:
- return string.strip(child.before)
+ return 0, string.strip(child.before)
elif index == 3:
return "TIMEOUT!!!"
--
1.7.1
12 years, 3 months
[libvirt] [test-API][PATCH 1/2] Reconnct libvirt after libvirtd restart
by Wayne Sun
In domain_nfs_start case, libvirtd will be restarted during test,
which broke existing connection. User need re-init connection in
test case, for this:
* Using sharedmod data dictionary to store Envparser class in
generator.
* Do not clear data dictionary in env_inspect, user can update
it or framework release it at last.
* Using sharemod_init in env_inspect to re-init conn in
domain_nfs_start.
Signed-off-by: Wayne Sun <gsun(a)redhat.com>
---
repos/sVirt/domain_nfs_start.py | 11 +++++++++--
src/env_inspect.py | 1 -
src/generator.py | 2 ++
3 files changed, 11 insertions(+), 3 deletions(-)
diff --git a/repos/sVirt/domain_nfs_start.py b/repos/sVirt/domain_nfs_start.py
index 88d349c..4d48d97 100644
--- a/repos/sVirt/domain_nfs_start.py
+++ b/repos/sVirt/domain_nfs_start.py
@@ -12,7 +12,7 @@ import sys
import libvirt
from libvirt import libvirtError
-
+from src import env_inspect
from src import sharedmod
from utils import utils
from shutil import copy
@@ -163,6 +163,8 @@ def domain_nfs_start(params):
logger.error("Error: fail to get domain %s xml" % guestname)
return 1
+ conn.close()
+
# set env
logger.info("prepare the environment")
ret = prepare_env(dynamic_ownership, virt_use_nfs, guestname, \
@@ -171,6 +173,11 @@ def domain_nfs_start(params):
logger.error("failed to prepare the environment")
return 1
+ # reconnect libvirt
+ env = sharedmod.data['env']
+ env_inspect.sharemod_init(env, logger)
+ conn = sharedmod.libvirtobj['conn']
+
domobj = conn.lookupByName(guestname)
logger.info("begin to test start domain from nfs storage")
@@ -283,7 +290,7 @@ def domain_nfs_start(params):
logger.error("Error: fail to get domain %s state" % guestname)
return 1
- if state != "shutoff":
+ if state != libvirt.VIR_DOMAIN_SHUTOFF:
logger.info("shut down the domain %s" % guestname)
try:
domobj.destroy()
diff --git a/src/env_inspect.py b/src/env_inspect.py
index b260ff8..a6dc4b1 100644
--- a/src/env_inspect.py
+++ b/src/env_inspect.py
@@ -98,7 +98,6 @@ def sharemod_init(env_parser, logger):
# initialize conn object in sharedmod
sharedmod.libvirtobj.clear()
- sharedmod.data.clear()
sharedmod.libvirtobj['conn'] = conn
return 0
diff --git a/src/generator.py b/src/generator.py
index 0cdc9de..f01f2fb 100644
--- a/src/generator.py
+++ b/src/generator.py
@@ -30,6 +30,7 @@ from testcasexml import xml_file_to_str
import env_parser
import env_inspect
import format
+import sharedmod
class FuncGen(object):
""" To generate a callable testcase"""
@@ -56,6 +57,7 @@ class FuncGen(object):
self.__case_info_save(activity, testrunid)
self.env = env_parser.Envparser("global.cfg")
+ sharedmod.data['env'] = self.env
mapper_obj = mapper.Mapper(activity)
case_list = mapper_obj.module_casename_func_map()
--
1.7.1
12 years, 3 months
[libvirt] [PATCH 00/17] Supports for hypervisor-pin and hypervisor-bandwidth
by Hu Tao
This series is a merge of
1) "Support hypervisor-threads-pin in vcpupin"
(https://www.redhat.com/archives/libvir-list/2012-July/msg01361.html)
2) "support to set cpu bandwidth for hypervisor threads"
(https://www.redhat.com/archives/libvir-list/2012-June/msg01161.html)
to make life easier because of the two share some patches.
Patches 1-12 are from 1), patches 13-17 are from 2).
Changes:
1. rebase to the latest git tree(removal of qemuReportError, split of virsh.c)
2. some typo fixes
3. make it pass syntax-check
Hu Tao (2):
limit cpu bandwidth only for vcpus
update doc about hypervisor_period/hypervisor_quota
Tang Chen (9):
Enable cpuset cgroup and synchronous vcpupin info to cgroup.
Support hypervisorpin xml parse.
Introduce qemuSetupCgroupHypervisorPin and synchronize hypervisorpin
info to cgroup.
Add qemuProcessSetHypervisorAffinites and set hypervisor threads
affinities
Introduce virDomainHypervisorPinAdd and virDomainHypervisorPinDel
functions
Introduce virDomainPinHypervisorFlags and
virDomainGetHypervisorPinInfo functions.
Introduce qemudDomainPinHypervisorFlags and
qemudDomainGetHypervisorPinInfo in qemu driver.
Introduce remoteDomainPinHypervisorFlags and
remoteDomainGetHypervisorPinInfo functions in remote driver.
Improve vcpupin to support hypervisorpin dynamically.
Wen Congyang (6):
Introduce the function virCgroupForHypervisor
Introduce the function virCgroupMoveTask
create a new cgroup and move all hypervisor threads to the new cgroup
Update XML Schema for new entries
qemu: Implement hypervisor's period and quota tunable XML
configuration and parsing
qemu: Implement hypervisor_period and hypervisor_quota's modification
daemon/remote.c | 103 +++++
docs/schemas/domaincommon.rng | 17 +
include/libvirt/libvirt.h.in | 26 ++
src/conf/domain_conf.c | 189 ++++++++-
src/conf/domain_conf.h | 9 +
src/driver.h | 13 +-
src/libvirt.c | 147 +++++++
src/libvirt_private.syms | 7 +
src/libvirt_public.syms | 2 +
src/qemu/qemu_cgroup.c | 193 ++++++++--
src/qemu/qemu_cgroup.h | 5 +
src/qemu/qemu_driver.c | 465 +++++++++++++++++++----
src/qemu/qemu_process.c | 60 ++-
src/remote/remote_driver.c | 102 +++++
src/remote/remote_protocol.x | 23 +-
src/remote_protocol-structs | 24 ++
src/util/cgroup.c | 188 ++++++++-
src/util/cgroup.h | 15 +
tests/qemuxml2argvdata/qemuxml2argv-cputune.xml | 1 +
tests/vcpupin | 6 +-
tools/virsh-domain.c | 147 ++++---
tools/virsh.pod | 23 +-
22 files changed, 1594 insertions(+), 171 deletions(-)
--
1.7.10.2
12 years, 3 months
[libvirt] [PATCH v5] ESX: Add routines to interface driver
by Ata E Husain Bohra
Add following routines to esx_interface_driver:
esxNumOfInterfaces,
esxNumOfDefinedInterfaces,
esxListInterfaces,
esxListDefinedInterfaces,
esxInterfaceLookupByMACString,
esxInterfaceGetXMLDesc,
esxInterfaceUndefine,
esxInterfaceCreate,
esxInterfaceDestroy
Signed-off-by: Ata E Husain Bohra <ata.husain(a)hotmail.com>
---
src/esx/esx_interface_driver.c | 551 +++++++++++++++++++++++++++++++++++++++-
src/esx/esx_vi.c | 125 +++++++++
src/esx/esx_vi.h | 10 +
src/esx/esx_vi_generator.input | 227 +++++++++++++++++
src/esx/esx_vi_generator.py | 23 ++
src/esx/esx_vi_types.c | 2 -
6 files changed, 934 insertions(+), 4 deletions(-)
diff --git a/src/esx/esx_interface_driver.c b/src/esx/esx_interface_driver.c
index 501409a..e9f0d4a 100644
--- a/src/esx/esx_interface_driver.c
+++ b/src/esx/esx_interface_driver.c
@@ -23,6 +23,9 @@
*/
#include <config.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
#include "internal.h"
#include "util.h"
@@ -34,6 +37,7 @@
#include "esx_vi.h"
#include "esx_vi_methods.h"
#include "esx_util.h"
+#include "interface_conf.h"
#define VIR_FROM_THIS VIR_FROM_ESX
@@ -67,10 +71,553 @@ esxInterfaceClose(virConnectPtr conn)
+static int
+esxNumOfInterfaces(virConnectPtr conn)
+{
+ bool success = false;
+ esxPrivate *priv = conn->interfacePrivateData;
+ esxVI_HostVirtualNic *hostVirtualNicList = NULL;
+ const esxVI_HostVirtualNic *hostVirtualNic = NULL;
+ int count = 0;
+
+ if (esxVI_EnsureSession(priv->primary) < 0 ||
+ esxVI_LookupHostVirtualNicList(priv->primary,
+ &hostVirtualNicList) < 0) {
+ goto cleanup;
+ }
+
+ if (hostVirtualNicList == NULL) {
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("Could not retrieve HostVirtualNic List"));
+
+ goto cleanup;
+ }
+
+ for (hostVirtualNic = hostVirtualNicList;
+ hostVirtualNic != NULL;
+ hostVirtualNic = hostVirtualNic->_next) {
+ count++;
+ }
+
+ success = true;
+
+cleanup:
+
+ esxVI_HostVirtualNic_Free(&hostVirtualNicList);
+
+ return success ? count : -1;
+
+}
+
+
+
+static int
+esxNumOfDefinedInterfaces(virConnectPtr conn ATTRIBUTE_UNUSED)
+{
+ // ESX interfaces are always active
+ return 0;
+
+}
+
+
+
+static int
+esxListInterfaces(virConnectPtr conn, char **names, int maxnames)
+{
+ int result = -1;
+ esxPrivate *priv = conn->interfacePrivateData;
+ esxVI_HostVirtualNic *hostVirtualNicList = NULL;
+ const esxVI_HostVirtualNic *hostVirtualNic = NULL;
+ int i = 0;
+
+ if (esxVI_EnsureSession(priv->primary) < 0 ||
+ esxVI_LookupHostVirtualNicList(priv->primary,
+ &hostVirtualNicList) < 0) {
+ goto cleanup;
+ }
+
+ if (hostVirtualNicList == NULL) {
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("Could not retrieve vNIC List"));
+ goto cleanup;
+ }
+
+ for (i= 0, hostVirtualNic = hostVirtualNicList;
+ hostVirtualNic != NULL && i < maxnames;
+ ++i, hostVirtualNic = hostVirtualNic->_next) {
+ names[i] = strdup(hostVirtualNic->device);
+
+ if (names[i] == NULL) {
+ for(;i >=0;--i) {
+ VIR_FREE(names[i]);
+ }
+ virReportOOMError();
+ goto cleanup;
+ }
+ }
+
+ result = i;
+
+ cleanup:
+
+ esxVI_HostVirtualNic_Free(&hostVirtualNicList);
+
+ return result;
+
+}
+
+
+
+static int
+esxListDefinedInterfaces(virConnectPtr conn ATTRIBUTE_UNUSED,
+ char **names ATTRIBUTE_UNUSED,
+ int maxnames ATTRIBUTE_UNUSED)
+{
+ // ESX interfaces are always active
+ return 0;
+
+}
+
+
+
+static virInterfacePtr
+esxInterfaceLookupByName(virConnectPtr conn, const char *name)
+{
+ virInterfacePtr ret = NULL;
+ esxPrivate *priv = conn->interfacePrivateData;
+ esxVI_HostVirtualNic *hostVirtualNicList = NULL;
+ const esxVI_HostVirtualNic *hostVirtualNic = NULL;
+
+ if (esxVI_EnsureSession(priv->primary) < 0 ||
+ esxVI_LookupHostVirtualNicList(priv->primary,
+ &hostVirtualNicList) < 0) {
+ goto cleanup;
+ }
+
+ if (hostVirtualNicList == 0) {
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("Could not retrieve HostVirtualNic List"));
+ goto cleanup;
+ }
+
+
+ for(hostVirtualNic = hostVirtualNicList;
+ hostVirtualNic != NULL;
+ hostVirtualNic = hostVirtualNic->_next) {
+ if (STREQ(hostVirtualNic->device, name)) {
+ if (hostVirtualNic->spec == NULL ||
+ hostVirtualNic->spec->mac == NULL) {
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("Malformed HostVirtualNicSpec"));
+ goto cleanup;
+ }
+
+ ret = virGetInterface(conn, hostVirtualNic->device,
+ hostVirtualNic->spec->mac);
+ break;
+ }
+ }
+
+ cleanup:
+
+ esxVI_HostVirtualNic_Free(&hostVirtualNicList);
+
+ return ret;
+
+}
+
+
+
+static virInterfacePtr
+esxInterfaceLookupByMACString(virConnectPtr conn, const char *mac)
+{
+ virInterfacePtr ret = NULL;
+ esxPrivate *priv = conn->interfacePrivateData;
+ esxVI_HostVirtualNic *hostVirtualNicList = NULL;
+ const esxVI_HostVirtualNic *hostVirtualNic = NULL;
+
+ if (esxVI_EnsureSession(priv->primary) < 0 ||
+ esxVI_LookupHostVirtualNicList(priv->primary,
+ &hostVirtualNicList) < 0) {
+ goto cleanup;
+ }
+
+ if (hostVirtualNicList == 0) {
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("Could not retrieve HostVirtualNic List"));
+ goto cleanup;
+ }
+
+
+ for(hostVirtualNic = hostVirtualNicList;
+ hostVirtualNic != NULL;
+ hostVirtualNic = hostVirtualNic->_next) {
+ if (hostVirtualNic->spec == NULL ||
+ hostVirtualNic->spec->mac == NULL) {
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("Malformed HostVirtualNicSpec"));
+ goto cleanup;
+ }
+
+ if (STREQ(hostVirtualNic->spec->mac, mac)) {
+ ret = virGetInterface(conn, hostVirtualNic->device,
+ hostVirtualNic->spec->mac);
+ break;
+ }
+ }
+
+ cleanup:
+
+ esxVI_HostVirtualNic_Free(&hostVirtualNicList);
+
+ return ret;
+
+}
+
+
+
+static char*
+esxInterfaceGetXMLDesc(virInterfacePtr iface, unsigned int flags)
+{
+ char *ret = NULL;
+ esxPrivate *priv = iface->conn->interfacePrivateData;
+ esxVI_HostVirtualNic *hostVirtualNicList = NULL;
+ const esxVI_HostVirtualNic *hostVirtualNic = NULL;
+ esxVI_PhysicalNic *physicalNicList = NULL;
+ const esxVI_PhysicalNic *physicalNic = NULL;
+ esxVI_PhysicalNic *matchingPhysicalNicList = NULL;
+ esxVI_HostIpRouteConfig *ipRouteConfig = NULL;
+ esxVI_HostPortGroup *hostPortGroupList = NULL;
+ esxVI_HostVirtualSwitch *hostVirtualSwitchList = NULL;
+ esxVI_String *propertyNameList = NULL;
+ esxVI_ObjectContent *hostSystem = NULL;
+ esxVI_DynamicProperty *dynamicProperty = NULL;
+ virInterfaceDefPtr def = NULL;
+ virInterfaceDefPtr itf = NULL;
+ int use_static = 0;
+ struct in_addr addr;
+ uint32_t host_addr = 0;
+ int zero_count = 0;
+ int masklen = 0;
+ int i = 0;
+
+ if (VIR_INTERFACE_XML_INACTIVE & flags) {
+ use_static = 1;
+ }
+
+ if (esxVI_EnsureSession(priv->primary) < 0 ||
+ esxVI_String_AppendValueListToList(&propertyNameList,
+ "config.network.vnic\0"
+ "config.network.ipRouteConfig\0"
+ "config.network.vswitch\0"
+ "config.network.pnic\0"
+ "config.network.portgroup\0") < 0 ||
+ esxVI_LookupHostSystemProperties(priv->primary, propertyNameList,
+ &hostSystem) < 0) {
+ goto cleanup;
+ }
+
+ for (dynamicProperty = hostSystem->propSet; dynamicProperty != NULL;
+ dynamicProperty = dynamicProperty->_next) {
+ if (STREQ(dynamicProperty->name, "config.network.vnic")) {
+ if (esxVI_HostVirtualNic_CastListFromAnyType(
+ dynamicProperty->val, &hostVirtualNicList) < 0) {
+ goto cleanup;
+ }
+ } else if (STREQ(dynamicProperty->name,
+ "config.network.ipRouteConfig")) {
+ if (esxVI_HostIpRouteConfig_CastFromAnyType(
+ dynamicProperty->val, &ipRouteConfig)) {
+ goto cleanup;
+ }
+ } else if (STREQ(dynamicProperty->name, "config.network.vswitch")) {
+ if (esxVI_HostVirtualSwitch_CastListFromAnyType
+ (dynamicProperty->val, &hostVirtualSwitchList) < 0) {
+ goto cleanup;
+ }
+ } else if (STREQ(dynamicProperty->name, "config.network.pnic")) {
+ if (esxVI_PhysicalNic_CastListFromAnyType(
+ dynamicProperty->val, &physicalNicList) < 0) {
+ goto cleanup;
+ }
+ } else if (STREQ(dynamicProperty->name, "config.network.portgroup")) {
+ if (esxVI_HostPortGroup_CastListFromAnyType(
+ dynamicProperty->val, &hostPortGroupList) < 0) {
+ goto cleanup;
+ }
+ } else {
+ VIR_WARN("Unexpected '%s' property", dynamicProperty->name);
+ }
+ }
+
+ if (!hostVirtualNicList ||
+ !ipRouteConfig ||
+ !hostVirtualSwitchList ||
+ !hostPortGroupList) {
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("Unable to retrieve network parameters"));
+
+ goto cleanup;
+ }
+
+ for (hostVirtualNic = hostVirtualNicList;
+ hostVirtualNic != NULL;
+ hostVirtualNic = hostVirtualNic->_next) {
+ if (STREQ(hostVirtualNic->device, iface->name)) {
+ break;
+ }
+ }
+
+ if (hostVirtualNic == NULL) {
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("Could not find HostVirtual Nic"));
+ goto cleanup;
+ }
+
+ if (esxVI_LookupPhysicalNicFromHostPortGroup(
+ hostVirtualNic->portgroup, hostPortGroupList,
+ hostVirtualSwitchList, physicalNicList,
+ &matchingPhysicalNicList) < 0) {
+ goto cleanup;
+ }
+
+ /*
+ * populate virInterfaceDef object to obtain
+ * libvirt interface domain xml.
+ */
+ if (VIR_ALLOC(def) < 0) {
+ virReportOOMError();
+ goto cleanup;
+ }
+
+ def->type = VIR_INTERFACE_TYPE_BRIDGE;
+ def->name = strdup(hostVirtualNic->device);
+ if (def->name == NULL) {
+ virReportOOMError();
+ goto cleanup;
+ }
+
+ if (hostVirtualNic->spec->mtu && hostVirtualNic->spec->mtu->value) {
+ def->mtu = hostVirtualNic->spec->mtu->value;
+ } else {
+ def->mtu = 1500;
+ }
+
+ def->startmode = VIR_INTERFACE_START_ONBOOT;
+
+ if (!use_static && hostVirtualNic->spec->mac) {
+ def->mac = strdup(hostVirtualNic->spec->mac);
+ if (def->mac == NULL) {
+ virReportOOMError();
+ goto cleanup;
+ }
+ }
+
+ /* TODO - Handle VLAN (via portgroup?) */
+ if (hostVirtualNic->spec->ip->subnetMask &&
+ *hostVirtualNic->spec->ip->subnetMask &&
+ inet_aton(hostVirtualNic->spec->ip->subnetMask, &addr) == 0) {
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("Error parsing netmask"));
+ goto cleanup;
+ }
+
+ host_addr = ntohl(addr.s_addr);
+ /* Calculate masklen */
+ for (i = 0; i < 32; ++i) {
+ if (host_addr & 0x01) {
+ break;
+ }
+ zero_count++;
+ host_addr >>= 1;
+ }
+ masklen = 32 - zero_count;
+
+ /* append protocol field */
+ def->nprotos = 1;
+ if (VIR_ALLOC_N(def->protos, def->nprotos) < 0) {
+ virReportOOMError();
+ goto cleanup;
+ }
+
+ /* TODO - Add IPv6 Support */
+ for (i = 0; i < def->nprotos; ++i) {
+ if (VIR_ALLOC(def->protos[i]) < 0) {
+ goto cleanup;
+ }
+
+ def->protos[i]->family = strdup("ipv4");
+ if (def->protos[i]->family == NULL) {
+ virReportOOMError();
+ goto cleanup;
+ }
+
+ if (hostVirtualNic->spec->ip->dhcp == 1) {
+ def->protos[i]->dhcp = 1;
+ }
+
+ def->protos[i]->nips = 1;
+ if (hostVirtualNic->spec->ip->dhcp != 1 || !use_static) {
+ if (hostVirtualNic->spec->ip->ipAddress &&
+ *hostVirtualNic->spec->ip->ipAddress) {
+ int j =0;
+ if (VIR_ALLOC_N(def->protos[i]->ips,
+ def->protos[i]->nips) < 0) {
+ virReportOOMError();
+ goto cleanup;
+ }
+
+ for (j=0; j < def->protos[i]->nips; ++j) {
+ if (VIR_ALLOC(def->protos[i]->ips[j]) < 0) {
+ virReportOOMError();
+ goto cleanup;
+ }
+
+ def->protos[i]->ips[0]->address =
+ strdup(hostVirtualNic->spec->ip->ipAddress);
+ if (def->protos[i]->ips[0] == NULL) {
+ virReportOOMError();
+ goto cleanup;
+ }
+
+ def->protos[i]->ips[0]->prefix = masklen;
+
+ def->protos[i]->gateway =
+ strdup(ipRouteConfig->defaultGateway);
+ if (def->protos[i]->gateway == NULL) {
+ virReportOOMError();
+ goto cleanup;
+ }
+ }
+ }
+ }
+ }
+
+ /* Add bridge information */
+ def->data.bridge.stp = 0; /* off */
+
+ /**
+ * traversing physical nic list twice, first to get total
+ * interfaces and second to populate interface items.
+ * Total Complexity ~= O(N); N should not be a large number.
+ */
+ for (physicalNic = matchingPhysicalNicList, i = 0; physicalNic != NULL;
+ physicalNic = physicalNic->_next, ++i) {
+ }
+
+ if ( i > 0) {
+ if (VIR_ALLOC_N(def->data.bridge.itf, i) < 0) {
+ virReportOOMError();
+ goto cleanup;
+ }
+
+ def->data.bridge.nbItf = i;
+ for (physicalNic = matchingPhysicalNicList, i = 0;
+ physicalNic != NULL;
+ physicalNic = physicalNic->_next, ++i) {
+ virInterfaceDefFree(itf);
+ if (VIR_ALLOC(itf) < 0) {
+ virReportOOMError();
+ goto cleanup;
+ }
+
+ itf->type = VIR_INTERFACE_TYPE_ETHERNET;
+ itf->name = strdup(physicalNic->device);
+ if (itf->name == NULL) {
+ virReportOOMError();
+ goto cleanup;
+ }
+
+ itf->mac = strdup(physicalNic->mac);
+ if (itf->mac == NULL) {
+ virReportOOMError();
+ goto cleanup;
+ }
+
+ def->data.bridge.itf[i] = itf;
+ itf = NULL; /* avoid double free */
+ }
+ }
+
+ ret = virInterfaceDefFormat(def);
+
+ cleanup:
+
+ esxVI_HostVirtualNic_Free(&hostVirtualNicList);
+ esxVI_PhysicalNic_Free(&physicalNicList);
+ esxVI_PhysicalNic_Free(&matchingPhysicalNicList);
+ esxVI_HostPortGroup_Free(&hostPortGroupList);
+ esxVI_HostVirtualSwitch_Free(&hostVirtualSwitchList);
+ esxVI_HostIpRouteConfig_Free(&ipRouteConfig);
+ esxVI_ObjectContent_Free(&hostSystem);
+ esxVI_String_Free(&propertyNameList);
+ virInterfaceDefFree(def);
+ virInterfaceDefFree(itf);
+
+ return ret;
+
+}
+
+
+
+static int
+esxInterfaceUndefine(virInterfacePtr iface)
+{
+ esxPrivate *priv = iface->conn->interfacePrivateData;
+
+ if (esxVI_RemoveVirtualNic(
+ priv->primary,
+ priv->primary->hostSystem->configManager->networkSystem,
+ iface->name) < 0) {
+ return -1;
+ }
+
+ return 0;
+
+}
+
+
+
+static int
+esxInterfaceCreate(virInterfacePtr iface ATTRIBUTE_UNUSED,
+ unsigned int flags)
+{
+ virCheckFlags(0, -1);
+
+ /* ESX interfaces are always active */
+ return 0;
+
+}
+
+
+
+static int
+esxInterfaceDestroy(virInterfacePtr iface ATTRIBUTE_UNUSED,
+ unsigned int flags)
+{
+ virCheckFlags(0, -1);
+
+ /* ESX interfaces can not be deactivated */
+ return 1;
+
+}
+
+
+
static virInterfaceDriver esxInterfaceDriver = {
.name = "ESX",
- .open = esxInterfaceOpen, /* 0.7.6 */
- .close = esxInterfaceClose, /* 0.7.6 */
+ .open = esxInterfaceOpen, /* 0.7.6 */
+ .close = esxInterfaceClose, /* 0.7.6 */
+ .numOfInterfaces = esxNumOfInterfaces, /* 0.9.x */
+ .numOfDefinedInterfaces = esxNumOfDefinedInterfaces, /* 0.9.x */
+ .listInterfaces = esxListInterfaces, /* 0.9.x */
+ .listDefinedInterfaces = esxListDefinedInterfaces, /* 0.9.x */
+ .interfaceLookupByName = esxInterfaceLookupByName, /* 0.9.x */
+ .interfaceLookupByMACString = esxInterfaceLookupByMACString, /* 0.9.x */
+ .interfaceGetXMLDesc = esxInterfaceGetXMLDesc, /* 0.9.x */
+ .interfaceUndefine = esxInterfaceUndefine, /* 0.9.x */
+ .interfaceCreate = esxInterfaceCreate, /* 0.9.x */
+ .interfaceDestroy = esxInterfaceDestroy, /* 0.9.x */
};
diff --git a/src/esx/esx_vi.c b/src/esx/esx_vi.c
index 2c789e1..962c9c2 100644
--- a/src/esx/esx_vi.c
+++ b/src/esx/esx_vi.c
@@ -4569,6 +4569,131 @@ esxVI_LookupManagedObjectHelper(esxVI_Context *ctx,
return result;
}
+int
+esxVI_LookupHostVirtualNicList(esxVI_Context* ctx,
+ esxVI_HostVirtualNic** virtualNicList)
+{
+ int result = -1;
+ esxVI_String *propertyNameList = NULL;
+ esxVI_DynamicProperty *dynamicProperty = NULL;
+ esxVI_ObjectContent* hostSystem = NULL;
+
+ if (esxVI_String_AppendValueListToList(
+ &propertyNameList, "config.network.vnic\0") < 0 ||
+ esxVI_LookupHostSystemProperties(ctx, propertyNameList,
+ &hostSystem) < 0) {
+ goto cleanup;
+ }
+
+ if (hostSystem == NULL) {
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("Could not retrieve the HostSystem object"));
+
+ goto cleanup;
+ }
+
+ for (dynamicProperty = hostSystem->propSet;
+ dynamicProperty != NULL;
+ dynamicProperty = dynamicProperty->_next) {
+ if (STREQ(dynamicProperty->name, "config.network.vnic")) {
+ if (esxVI_HostVirtualNic_CastListFromAnyType(
+ dynamicProperty->val, virtualNicList) < 0) {
+ goto cleanup;
+ }
+ break;
+ } else {
+ VIR_WARN("Unexpected '%s' property", dynamicProperty->name);
+ }
+ }
+
+ result = 0;
+
+cleanup:
+ esxVI_String_Free(&propertyNameList);
+ esxVI_ObjectContent_Free(&hostSystem);
+
+ return result;
+}
+
+int
+esxVI_LookupPhysicalNicFromHostPortGroup(
+ const char *portgroup,
+ const esxVI_HostPortGroup *hostPortGroupList,
+ const esxVI_HostVirtualSwitch *hostVirtualSwitchList,
+ const esxVI_PhysicalNic *physicalNicList,
+ esxVI_PhysicalNic **ret_physicalNicList)
+{
+ int result = -1;
+ const esxVI_HostPortGroup *hostPortGroup = NULL;
+ const esxVI_HostVirtualSwitch *hostVirtualSwitch = NULL;
+ const esxVI_PhysicalNic *physicalNic = NULL;
+ esxVI_PhysicalNic *tempPhysicalNic = NULL;
+ const esxVI_String *pnicKey = NULL;
+ if (portgroup == NULL) {
+ goto cleanup;
+ }
+
+ /* Go through all the port groups to find the one that matches. */
+ for (hostPortGroup = hostPortGroupList;
+ hostPortGroup != NULL;
+ hostPortGroup = hostPortGroup->_next) {
+ if (STREQ(hostPortGroup->spec->name, portgroup)) {
+ break;
+ }
+ }
+
+ if (hostPortGroup == NULL) {
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("Could not find Host port group"));
+ goto cleanup;
+ }
+
+ /* Go through all the virtual switches to find the one that matches */
+ for (hostVirtualSwitch = hostVirtualSwitchList;
+ hostVirtualSwitch != NULL;
+ hostVirtualSwitch = hostVirtualSwitch->_next) {
+ if (STREQ(hostPortGroup->spec->vswitchName, hostVirtualSwitch->name)) {
+ break;
+ }
+ }
+
+ if (hostVirtualSwitch == NULL) {
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("Could not find Virtual Switch"));
+ goto cleanup;
+ }
+
+ /* Go through all physical nics */
+ for (pnicKey = hostVirtualSwitch->pnic;
+ pnicKey != NULL;
+ pnicKey = pnicKey->_next) {
+ /* O(n^2), but probably faster than a hash due to small N */
+ for (physicalNic = physicalNicList;
+ physicalNic != NULL;
+ physicalNic = physicalNic->_next) {
+
+ esxVI_PhysicalNic_Free(&tempPhysicalNic);
+
+ if (STREQ(pnicKey->value, physicalNic->key)) {
+ if (esxVI_PhysicalNic_DeepCopy(
+ &tempPhysicalNic, (esxVI_PhysicalNic *)physicalNic) < 0 ||
+ esxVI_PhysicalNic_AppendToList(
+ ret_physicalNicList, tempPhysicalNic) < 0) {
+ goto cleanup;
+ }
+ tempPhysicalNic = NULL;
+ }
+ }
+ }
+
+ result = 0;
+
+ cleanup:
+
+ esxVI_PhysicalNic_Free(&tempPhysicalNic);
+
+ return result;
+}
#include "esx_vi.generated.c"
diff --git a/src/esx/esx_vi.h b/src/esx/esx_vi.h
index 4b84be8..0eb9a99 100644
--- a/src/esx/esx_vi.h
+++ b/src/esx/esx_vi.h
@@ -499,6 +499,16 @@ int esxVI_ParseHostCpuIdInfo(esxVI_ParsedHostCpuIdInfo *parsedHostCpuIdInfo,
int esxVI_ProductVersionToDefaultVirtualHWVersion(esxVI_ProductVersion productVersion);
+int esxVI_LookupHostVirtualNicList(esxVI_Context* ctx,
+ esxVI_HostVirtualNic** virtualNicList);
+
+int esxVI_LookupPhysicalNicFromHostPortGroup(
+ const char *portgroup,
+ const esxVI_HostPortGroup *portGroupList,
+ const esxVI_HostVirtualSwitch *virtualSwitchList,
+ const esxVI_PhysicalNic *physicalNicList,
+ esxVI_PhysicalNic **ret_physicalNicList);
+
# include "esx_vi.generated.h"
#endif /* __ESX_VI_H__ */
diff --git a/src/esx/esx_vi_generator.input b/src/esx/esx_vi_generator.input
index 1a67a8c..64f8389 100644
--- a/src/esx/esx_vi_generator.input
+++ b/src/esx/esx_vi_generator.input
@@ -57,6 +57,29 @@ enum AutoStartWaitHeartbeatSetting
systemDefault
end
+enum HostConfigChangeOperation
+ add
+ edit
+ remove
+end
+
+enum HostIpConfigIpV6AdressStatus
+ deprecated
+ duplicate
+ inaccessible
+ invalid
+ preferred
+ tentative
+ unknown
+end
+
+enum HostIpConfigV6AdressConfigType
+ dhcp
+ linklayer
+ manual
+ other
+ random
+end
enum ManagedEntityStatus
gray
@@ -197,6 +220,12 @@ object DeviceBackedVirtualDiskSpec extends VirtualDiskSpec
String device r
end
+object DistributedVirtualSwitchPortConnection
+ Int connectionCookie o
+ String portgroupKey o
+ String portKey o
+ String switchUuid r
+end
object DynamicProperty
String name r
@@ -316,6 +345,34 @@ object HostFileSystemVolume
Long capacity r
end
+object HostIpConfig
+ Boolean dhcp r
+ String ipAddress o
+ HostIpConfigIpV6AddressConfiguration ipV6Config o
+ String subnetMask o
+end
+
+object HostIpConfigIpV6Address
+ String dadState o
+ String ipAddress r
+ DateTime lifetime o
+ String operation o
+ String origin o
+ Int prefixLength r
+end
+
+object HostIpConfigIpV6AddressConfiguration
+ Boolean autoConfigurationEnabled o
+ Boolean dhcpV6Enabled o
+ HostIpConfigIpV6Address ipV6Address ol
+end
+
+object HostIpRouteConfig
+ String defaultGateway o
+ String gatewayDevice o
+ String ipV6DefaultGateway o
+ String ipV6GatewayDevice o
+end
object HostMountInfo
String path o
@@ -331,11 +388,131 @@ object HostNasVolume extends HostFileSystemVolume
end
+object HostNicTeamingPolicy
+ String policy o
+ Boolean reversePolicy o
+ Boolean notifySwitches o
+ Boolean rollingOrder o
+ HostNicFailureCriteria failureCriteria o
+ HostNicOrderPolicy nicOrder o
+end
+
+object HostNetOffloadCapabilities
+ Boolean csumOffload o
+ Boolean tcpSegmentation o
+ Boolean zeroCopyXmit o
+end
+
+object HostNetworkSecurityPolicy
+ Boolean allowPromiscuous o
+ Boolean macChanges o
+ Boolean forgedTransmits o
+end
+
+object HostNetworkPolicy
+ HostNetworkSecurityPolicy security o
+ HostNicTeamingPolicy nicTeaming o
+ HostNetOffloadCapabilities offloadPolicy o
+ HostNetworkTrafficShapingPolicy shapingPolicy o
+end
+
+object HostNetworkTrafficShapingPolicy
+ Boolean enabled o
+end
+
+object HostNicFailureCriteria
+ String checkSpeed o
+ Int speed o
+ Boolean checkDuplex o
+ Boolean fullDuplex o
+ Boolean checkErrorPercent o
+ Int percentage o
+ Boolean checkBeacon o
+end
+
+object HostNicOrderPolicy
+ String activeNic ol
+ String standbyNic ol
+end
+
+object HostPortGroup
+ String key r
+ HostPortGroupPort port ol
+ String vswitch r
+ HostNetworkPolicy computedPolicy r
+ HostPortGroupSpec spec r
+end
+
+object HostPortGroupPort
+ String key o
+ String mac ol
+ String type r
+end
+
+object HostPortGroupSpec
+ String name r
+ Int vlanId r
+ String vswitchName r
+ HostNetworkPolicy policy r
+end
+
object HostScsiDiskPartition
String diskName r
Int partition r
end
+object HostVirtualNic
+ String device r
+ String key r
+ String port o
+ String portgroup r
+ HostVirtualNicSpec spec r
+end
+
+object HostVirtualNicSpec
+ DistributedVirtualSwitchPortConnection distributedVirtualPort o
+ HostIpConfig ip o
+ String mac o
+ Int mtu o
+ String portgroup o
+ Boolean tsoEnabled o
+end
+
+
+object HostVirtualSwitch
+ String key r
+ Int mtu o
+ String name r
+ Int numPorts r
+ Int numPortsAvailable r
+ String pnic ol
+ String portgroup ol
+ HostVirtualSwitchSpec spec r
+end
+
+object HostVirtualSwitchBridge
+end
+
+object HostVirtualSwitchAutoBridge extends HostVirtualSwitchBridge
+ String excludedNicDevice ol
+end
+
+object HostVirtualSwitchBeaconBridge extends HostVirtualSwitchBridge
+ Int interval r
+end
+
+object HostVirtualSwitchBondBridge extends HostVirtualSwitchBridge
+ HostVirtualSwitchBeaconBridge beacon o
+ LinkDiscoveryProtocolConfig linkDiscoveryProtocolConfig o
+ String nicDevice rl
+end
+
+object HostVirtualSwitchSpec
+ HostVirtualSwitchBridge bridge o
+ Int mtu o
+ Int numPorts r
+ HostNetworkPolicy policy o
+end
object HostVmfsVolume extends HostFileSystemVolume
Int blockSizeMb r
@@ -355,6 +532,10 @@ end
object IsoImageFileQuery extends FileQuery
end
+object LinkDiscoveryProtocolConfig
+ String operation r
+ String protocol r
+end
object LocalDatastoreInfo extends DatastoreInfo
String path o
@@ -398,6 +579,10 @@ object OptionType
Boolean valueIsReadonly o
end
+object OptionValue
+ String key r
+ AnyType value r
+end
object PerfCounterInfo
Int key r
@@ -454,6 +639,27 @@ object PerfSampleInfo
Int interval r
end
+object PhysicalNic
+ String device r
+ String driver o
+ String key o
+ PhysicalNicInfo linkSpeed o
+ String mac r
+ String pci r
+ PhysicalNicSpec spec r
+ PhysicalNicInfo validLinkSpecification ol
+ Boolean wakeOnLanSupported r
+end
+
+object PhysicalNicInfo
+ Boolean duplex r
+ Int speedMb r
+end
+
+object PhysicalNicSpec
+ HostIpConfig ip o
+ PhysicalNicInfo linkSpeed o
+end
object PropertyChange
String name r
@@ -773,6 +979,13 @@ end
# Methods
#
+method AddVirtualNic returns String r
+ ManagedObjectReference _this r
+ String portgroup r
+ HostVirtualNicSpec nic r
+end
+
+
method AnswerVM
ManagedObjectReference _this r
String questionId r
@@ -954,6 +1167,10 @@ method RemoveSnapshot_Task returns ManagedObjectReference r
Boolean removeChildren r
end
+method RemoveVirtualNic
+ ManagedObjectReference _this r
+ String device r
+end
method RetrieveProperties returns ObjectContent ol
ManagedObjectReference _this:propertyCollector r
@@ -1002,6 +1219,16 @@ method UnregisterVM
ManagedObjectReference _this r
end
+method UpdateIpRouteConfig
+ ManagedObjectReference _this r
+ HostIpRouteConfig config r
+end
+
+method UpdateVirtualNic
+ ManagedObjectReference _this r
+ String device r
+ HostVirtualNicSpec nic r
+end
method WaitForUpdates returns UpdateSet r
ManagedObjectReference _this:propertyCollector r
diff --git a/src/esx/esx_vi_generator.py b/src/esx/esx_vi_generator.py
index 910478c..26ae62e 100755
--- a/src/esx/esx_vi_generator.py
+++ b/src/esx/esx_vi_generator.py
@@ -1519,8 +1519,31 @@ additional_object_features = { "AutoStartDefaults" : Object.FEATURE__AN
Object.FEATURE__ANY_TYPE,
"HostDatastoreBrowserSearchResults" : Object.FEATURE__LIST |
Object.FEATURE__ANY_TYPE,
+ "HostIpConfig" : Object.FEATURE__DEEP_COPY,
+ "HostIpRouteConfig" : Object.FEATURE__ANY_TYPE,
+ "HostIpConfigIpV6Address" : Object.FEATURE__LIST |
+ Object.FEATURE__ANY_TYPE |
+ Object.FEATURE__DEEP_COPY,
+ "HostIpConfigIpV6AddressConfiguration" : Object.FEATURE__DEEP_COPY,
+ "HostPortGroup" : Object.FEATURE__LIST |
+ Object.FEATURE__ANY_TYPE,
+ "HostVirtualNic" : Object.FEATURE__ANY_TYPE |
+ Object.FEATURE__LIST,
+ "HostVirtualSwitch" : Object.FEATURE__ANY_TYPE |
+ Object.FEATURE__LIST,
+ "KeyValue" : Object.FEATURE__ANY_TYPE,
"ManagedObjectReference" : Object.FEATURE__ANY_TYPE,
+ "PhysicalNic" : Object.FEATURE__LIST |
+ Object.FEATURE__ANY_TYPE |
+ Object.FEATURE__DEEP_COPY,
"ObjectContent" : Object.FEATURE__DEEP_COPY,
+ "OptionValue" : Object.FEATURE__ANY_TYPE |
+ Object.FEATURE__LIST,
+ "PhysicalNic" : Object.FEATURE__LIST |
+ Object.FEATURE__ANY_TYPE |
+ Object.FEATURE__DEEP_COPY,
+ "PhysicalNicSpec" : Object.FEATURE__DEEP_COPY,
+ "PhysicalNicLinkInfo" : Object.FEATURE__LIST,
"ResourcePoolResourceUsage" : Object.FEATURE__ANY_TYPE,
"ServiceContent" : Object.FEATURE__DESERIALIZE,
"SharesInfo" : Object.FEATURE__ANY_TYPE,
diff --git a/src/esx/esx_vi_types.c b/src/esx/esx_vi_types.c
index 708aeda..d074e69 100644
--- a/src/esx/esx_vi_types.c
+++ b/src/esx/esx_vi_types.c
@@ -475,8 +475,6 @@
continue; \
}
-
-
/*
* A required property must be != 0 (NULL for pointers, "undefined" == 0 for
* enumeration values).
--
1.7.9.5
12 years, 3 months
[libvirt] [PATCH] util: include stderr in log message when an external command fails
by Laine Stump
This patch is in response to:
https://bugzilla.redhat.com/show_bug.cgi?id=818467
If a caller to virCommandRun doesn't ask for the exitstatus of the
program it's running, the virCommand functions assume that they should
log an error message and return failure if the exit code isn't
0. However, only the commandline and exit status are logged, while
potentially useful information sent by the program to stderr is
discarded.
Fortunately, virCommandRun is already checking if the caller had asked
for stderr to be saved and, if not, sets things up to save it in
*cmd->errbuf. This makes it fairly simple for virCommandWait to
include *cmd->errbuf in the error log (there are still other callers
that don't setup errbuf, and even virCommandRun won't set it up if the
command is being daemonized, so we have to check that it's non-zero).
---
Note that the minor change to the first virReportError string was made
because I noticed that virCommandTranslateStatus already puts the word
"status" in its string. The new message is less awkward.
src/util/command.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/src/util/command.c b/src/util/command.c
index 334ca89..7755572 100644
--- a/src/util/command.c
+++ b/src/util/command.c
@@ -2269,7 +2269,7 @@ virPidWait(pid_t pid, int *exitstatus)
if (status != 0) {
char *st = virCommandTranslateStatus(status);
virReportError(VIR_ERR_INTERNAL_ERROR,
- _("Child process (%lld) status unexpected: %s"),
+ _("Child process (%lld) unexpected %s"),
(long long) pid, NULLSTR(st));
VIR_FREE(st);
return -1;
@@ -2327,9 +2327,13 @@ virCommandWait(virCommandPtr cmd, int *exitstatus)
if (status) {
char *str = virCommandToString(cmd);
char *st = virCommandTranslateStatus(status);
+ bool haveErrMsg = cmd->errbuf && *cmd->errbuf && (*cmd->errbuf)[0];
+
virReportError(VIR_ERR_INTERNAL_ERROR,
- _("Child process (%s) status unexpected: %s"),
- str ? str : cmd->args[0], NULLSTR(st));
+ _("Child process (%s) unexpected %s%s%s"),
+ str ? str : cmd->args[0], NULLSTR(st),
+ haveErrMsg ? ": " : "",
+ haveErrMsg ? *cmd->errbuf : "");
VIR_FREE(str);
VIR_FREE(st);
return -1;
--
1.7.11.2
12 years, 3 months
[libvirt] [ANNOUNCE] libvirt-glib 0.1.1 release
by Zeeshan Ali (Khattak)
I am pleased to announce that a new release of the libvirt-glib package,
version 0.1.1 is now available from
ftp://libvirt.org/libvirt/glib/
The packages are GPG signed with
Key fingerprint: DE11 B48B FDC1 6349 4312 0860 FCAC ABEE 62D1 1E4C (2048R)
New in this release:
- Add bindings for virDomainSnapshotCreate*().
- Add bindings for virDomainRestore*().
- Add GVir.DomainShutdownFlags() binding.
- Add GVir.DomainXMLFlags binding.
libvirt-glib comprises three distinct libraries:
- libvirt-glib - Integrate with the GLib event loop and error handling
- libvirt-gconfig - Representation of libvirt XML documents as GObjects
- libvirt-gobject - Mapping of libvirt APIs into the GObject type system
NB: While libvirt aims to be API/ABI stable forever, with libvirt-glib
we are not yet guaranteeing that libvirt-glib libraries are API/ABI
permanently stable. As of the 0.0.8 release, we have tentatively frozen
the API/ABI with the intent of being longterm stable hereafter, but
there is still a small chance we might find flaws requiring an API/ABI
change. The likelihood of this is low, however, and we will strive to
avoid it.
Follow up comments about libvirt-glib should be directed to the regular
libvir-list redhat com development list.
Thanks to all the people involved in contributing to this release.
--
Regards,
Zeeshan Ali (Khattak)
FSF member#5124
12 years, 3 months
[libvirt] [PATCH v5 0/6] file descriptor passing using fd sets
by Corey Bryant
libvirt's sVirt security driver provides SELinux MAC isolation for
Qemu guest processes and their corresponding image files. In other
words, sVirt uses SELinux to prevent a QEMU process from opening
files that do not belong to it.
sVirt provides this support by labeling guests and resources with
security labels that are stored in file system extended attributes.
Some file systems, such as NFS, do not support the extended
attribute security namespace, and therefore cannot support sVirt
isolation.
A solution to this problem is to provide fd passing support, where
libvirt opens files and passes file descriptors to QEMU. This,
along with SELinux policy to prevent QEMU from opening files, can
provide image file isolation for NFS files stored on the same NFS
mount.
This patch series adds the add-fd, remove-fd, and query-fdsets
QMP monitor commands, which allow file descriptors to be passed
via SCM_RIGHTS, and assigned to specified fd sets. This allows
fd sets to be created per file with fds having, for example,
different access rights. When QEMU needs to reopen a file with
different access rights, it can search for a matching fd in the
fd set. Fd sets also allow for easy tracking of fds per file,
helping to prevent fd leaks.
Support is also added to the block layer to allow QEMU to dup an
fd from an fdset when the filename is of the /dev/fdset/nnn format,
where nnn is the fd set ID.
No new SELinux policy is required to prevent open of NFS files
(files with type nfs_t). The virt_use_nfs boolean type simply
needs to be set to false, and open will be prevented (and dup will
be allowed). For example:
# setsebool virt_use_nfs 0
# getsebool virt_use_nfs
virt_use_nfs --> off
Corey Bryant (6):
qemu-char: Add MSG_CMSG_CLOEXEC flag to recvmsg
qapi: Introduce add-fd, remove-fd, query-fdsets
monitor: Clean up fd sets on monitor disconnect
block: Convert open calls to qemu_open
block: Convert close calls to qemu_close
block: Enable qemu_open/close to work with fd sets
block/raw-posix.c | 42 ++++-----
block/raw-win32.c | 6 +-
block/vdi.c | 5 +-
block/vmdk.c | 25 +++---
block/vpc.c | 4 +-
block/vvfat.c | 16 ++--
cutils.c | 5 ++
monitor.c | 244 ++++++++++++++++++++++++++++++++++++++++++++++++++++-
monitor.h | 4 +
osdep.c | 141 +++++++++++++++++++++++++++++++
qapi-schema.json | 97 +++++++++++++++++++++
qemu-char.c | 10 ++-
qemu-common.h | 2 +
qemu-tool.c | 12 +++
qmp-commands.hx | 121 ++++++++++++++++++++++++++
savevm.c | 4 +-
16 files changed, 684 insertions(+), 54 deletions(-)
--
1.7.10.4
12 years, 3 months