[libvirt] [PATCH] add an assert, to avoid a false-positive NULL-deref warning from clang
by Jim Meyering
Here's a case in which using an assertion appears to be the only
way to tell clang that "client" really is non-NULL at that point.
I'm sure clang's analyzers will eventually improve, and hence avoid
this sort of false positive, so have marked this with a FIXME comment,
to help ensure we eventually remove this otherwise unnecessary assertion.
>From ba26bad7aec8713ded0fd3300e951eac3673cc72 Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering(a)redhat.com>
Date: Mon, 1 Mar 2010 15:19:48 +0100
Subject: [PATCH] add an assert, to avoid a false-positive NULL-deref warning from clang
* daemon/libvirtd.c (qemudWorker): Assert.
---
daemon/libvirtd.c | 5 +++++
1 files changed, 5 insertions(+), 0 deletions(-)
diff --git a/daemon/libvirtd.c b/daemon/libvirtd.c
index 9bdbecb..a357914 100644
--- a/daemon/libvirtd.c
+++ b/daemon/libvirtd.c
@@ -24,34 +24,35 @@
#include <config.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <sys/stat.h>
#include <unistd.h>
#include <fcntl.h>
#include <limits.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <sys/poll.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
#include <netdb.h>
#include <stdlib.h>
#include <pwd.h>
#include <stdio.h>
+#include <assert.h>
#include <stdarg.h>
#include <syslog.h>
#include <string.h>
#include <errno.h>
#include <getopt.h>
#include <fnmatch.h>
#include <grp.h>
#include <signal.h>
#include <netdb.h>
#include "libvirt_internal.h"
#include "virterror_internal.h"
#define VIR_FROM_THIS VIR_FROM_QEMU
#include "libvirtd.h"
#include "dispatch.h"
@@ -1504,34 +1505,38 @@ static void *qemudWorker(void *data)
virMutexLock(&server->lock);
while (((client = qemudPendingJob(server)) == NULL) &&
!worker->quitRequest) {
if (virCondWait(&server->job, &server->lock) < 0) {
virMutexUnlock(&server->lock);
return NULL;
}
}
if (worker->quitRequest) {
if (client)
virMutexUnlock(&client->lock);
virMutexUnlock(&server->lock);
return NULL;
}
worker->processingCall = 1;
virMutexUnlock(&server->lock);
+ /* Tell clang we know what we're doing.
+ FIXME: remove when clang improves. */
+ assert (client);
+
/* We own a locked client now... */
client->refs++;
/* Remove our message from dispatch queue while we use it */
msg = qemudClientMessageQueueServe(&client->dx);
/* This function drops the lock during dispatch,
* and re-acquires it before returning */
if (remoteDispatchClientRequest (server, client, msg) < 0) {
VIR_FREE(msg);
qemudDispatchClientFailure(client);
client->refs--;
virMutexUnlock(&client->lock);
continue;
}
client->refs--;
--
1.7.0.1.414.g89213d
14 years, 10 months
[libvirt] [RFC PATCH] build: consistently use C99 varargs macros
by Eric Blake
Prior to this patch, there was an inconsistent mix between GNU and
C99. For consistency, and potential portability to other compilers,
stick with the C99 vararg macro syntax.
* src/conf/cpu_conf.c (virCPUReportError): Use C99 rather than GNU
vararg macro syntax.
* src/conf/domain_conf.c (virDomainReportError): Likewise.
* src/conf/domain_event.c (eventReportError): Likewise.
* src/conf/interface_conf.c (virInterfaceReportError): Likewise.
* src/conf/network_conf.c (virNetworkReportError): Likewise.
* src/conf/node_device_conf.h (virNodeDeviceReportError):
Likewise.
* src/conf/secret_conf.h (virSecretReportError): Likewise.
* src/conf/storage_conf.h (virStorageReportError): Likewise.
---
Any objections to expanding this into a full-blown patch series? This
touches 8 files; I counted 43 more files that could be altered, using:
$ git grep -l 'define.*[a-zA-Z]\.\.\.'
src/conf/cpu_conf.c | 4 ++--
src/conf/domain_conf.c | 4 ++--
src/conf/domain_event.c | 5 +++--
src/conf/interface_conf.c | 4 ++--
src/conf/network_conf.c | 6 +++---
src/conf/node_device_conf.h | 5 +++--
src/conf/secret_conf.h | 6 +++---
src/conf/storage_conf.h | 6 +++---
8 files changed, 21 insertions(+), 19 deletions(-)
diff --git a/src/conf/cpu_conf.c b/src/conf/cpu_conf.c
index ed83188..612e376 100644
--- a/src/conf/cpu_conf.c
+++ b/src/conf/cpu_conf.c
@@ -31,9 +31,9 @@
#define VIR_FROM_THIS VIR_FROM_CPU
-#define virCPUReportError(code, fmt...) \
+#define virCPUReportError(code, ...) \
virReportErrorHelper(NULL, VIR_FROM_CPU, code, __FILE__, \
- __FUNCTION__, __LINE__, fmt)
+ __FUNCTION__, __LINE__, __VA_ARGS__)
VIR_ENUM_IMPL(virCPUMatch, VIR_CPU_MATCH_LAST,
"minimum",
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 4420445..ea84863 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -232,9 +232,9 @@ VIR_ENUM_IMPL(virDomainNetdevMacvtap, VIR_DOMAIN_NETDEV_MACVTAP_MODE_LAST,
"private",
"bridge")
-#define virDomainReportError(code, fmt...) \
+#define virDomainReportError(code, ...) \
virReportErrorHelper(NULL, VIR_FROM_DOMAIN, code, __FILE__, \
- __FUNCTION__, __LINE__, fmt)
+ __FUNCTION__, __LINE__, __VA_ARGS__)
#ifndef PROXY
diff --git a/src/conf/domain_event.c b/src/conf/domain_event.c
index b474b1c..e791cab 100644
--- a/src/conf/domain_event.c
+++ b/src/conf/domain_event.c
@@ -1,6 +1,7 @@
/*
* domain_event.c: domain event queue processing helpers
*
+ * Copyright (C) 2010 Red Hat, Inc.
* Copyright (C) 2008 VirtualIron
*
* This library is free software; you can redistribute it and/or
@@ -30,9 +31,9 @@
#define VIR_FROM_THIS VIR_FROM_NONE
-#define eventReportError(conn, code, fmt...) \
+#define eventReportError(conn, code, ...) \
virReportErrorHelper(conn, VIR_FROM_THIS, code, __FILE__, \
- __FUNCTION__, __LINE__, fmt)
+ __FUNCTION__, __LINE__, __VA_ARGS__)
/**
diff --git a/src/conf/interface_conf.c b/src/conf/interface_conf.c
index a0d2dfa..bc9e958 100644
--- a/src/conf/interface_conf.c
+++ b/src/conf/interface_conf.c
@@ -45,9 +45,9 @@ static int
virInterfaceDefDevFormat(virBufferPtr buf,
const virInterfaceDefPtr def, int level);
-#define virInterfaceReportError(code, fmt...) \
+#define virInterfaceReportError(code, ...) \
virReportErrorHelper(NULL, VIR_FROM_INTERFACE, code, __FILE__, \
- __FUNCTION__, __LINE__, fmt)
+ __FUNCTION__, __LINE__, __VA_ARGS__)
static
void virInterfaceIpDefFree(virInterfaceIpDefPtr def) {
diff --git a/src/conf/network_conf.c b/src/conf/network_conf.c
index 6d3c3c0..39ebd62 100644
--- a/src/conf/network_conf.c
+++ b/src/conf/network_conf.c
@@ -1,7 +1,7 @@
/*
* network_conf.c: network XML handling
*
- * Copyright (C) 2006-2009 Red Hat, Inc.
+ * Copyright (C) 2006-2010 Red Hat, Inc.
* Copyright (C) 2006-2008 Daniel P. Berrange
*
* This library is free software; you can redistribute it and/or
@@ -53,9 +53,9 @@ VIR_ENUM_IMPL(virNetworkForward,
VIR_NETWORK_FORWARD_LAST,
"none", "nat", "route" )
-#define virNetworkReportError(code, fmt...) \
+#define virNetworkReportError(code, ...) \
virReportErrorHelper(NULL, VIR_FROM_NETWORK, code, __FILE__, \
- __FUNCTION__, __LINE__, fmt)
+ __FUNCTION__, __LINE__, __VA_ARGS__)
virNetworkObjPtr virNetworkFindByUUID(const virNetworkObjListPtr nets,
const unsigned char *uuid)
diff --git a/src/conf/node_device_conf.h b/src/conf/node_device_conf.h
index 3a5432c..cbaad9b 100644
--- a/src/conf/node_device_conf.h
+++ b/src/conf/node_device_conf.h
@@ -1,6 +1,7 @@
/*
* node_device_conf.h: config handling for node devices
*
+ * Copyright (C) 2010 Red Hat, Inc.
* Copyright (C) 2008 Virtual Iron Software, Inc.
* Copyright (C) 2008 David F. Lively
*
@@ -217,9 +218,9 @@ struct _virDeviceMonitorState {
void *privateData; /* driver-specific private data */
};
-#define virNodeDeviceReportError(code, fmt...) \
+#define virNodeDeviceReportError(code, ...) \
virReportErrorHelper(NULL, VIR_FROM_NODEDEV, code, __FILE__, \
- __FUNCTION__, __LINE__, fmt)
+ __FUNCTION__, __LINE__, __VA_ARGS__)
int virNodeDeviceHasCap(const virNodeDeviceObjPtr dev, const char *cap);
diff --git a/src/conf/secret_conf.h b/src/conf/secret_conf.h
index da00920..afcf8f1 100644
--- a/src/conf/secret_conf.h
+++ b/src/conf/secret_conf.h
@@ -1,7 +1,7 @@
/*
* secret_conf.h: internal <secret> XML handling API
*
- * Copyright (C) 2009 Red Hat, Inc.
+ * Copyright (C) 2009-2010 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -26,9 +26,9 @@
#include "internal.h"
#include "util.h"
-#define virSecretReportError(code, fmt...) \
+#define virSecretReportError(code, ...) \
virReportErrorHelper(NULL, VIR_FROM_SECRET, code, __FILE__, \
- __FUNCTION__, __LINE__, fmt)
+ __FUNCTION__, __LINE__, __VA_ARGS__)
VIR_ENUM_DECL(virSecretUsageType)
diff --git a/src/conf/storage_conf.h b/src/conf/storage_conf.h
index c643984..5441c8e 100644
--- a/src/conf/storage_conf.h
+++ b/src/conf/storage_conf.h
@@ -1,7 +1,7 @@
/*
* storage_conf.h: config handling for storage driver
*
- * Copyright (C) 2006-2008 Red Hat, Inc.
+ * Copyright (C) 2006-2008, 2010 Red Hat, Inc.
* Copyright (C) 2006-2008 Daniel P. Berrange
*
* This library is free software; you can redistribute it and/or
@@ -318,9 +318,9 @@ static inline int virStoragePoolObjIsActive(virStoragePoolObjPtr pool) {
return pool->active;
}
-#define virStorageReportError(code, fmt...) \
+#define virStorageReportError(code, ...) \
virReportErrorHelper(NULL, VIR_FROM_STORAGE, code, __FILE__, \
- __FUNCTION__, __LINE__, fmt)
+ __FUNCTION__, __LINE__, __VA_ARGS__)
int virStoragePoolLoadAllConfigs(virStoragePoolObjListPtr pools,
const char *configDir,
--
1.6.6.1
14 years, 10 months
[libvirt] [RFC] Proposal for introduction of network traffic filtering capabilities for filtering of network traffic from and to VMs
by Stefan Berger
Hello!
The following is a proposal to introduce network traffic filtering
capabilities for the network traffic originating from and destined to
virtual machines. Libvirt's capabilities will be extended to allow users
to describe what traffic filtering rules are to be applied on a virtual
machine (using XML) and libvirt then creates the appropriate ebtables and
iptables rules and applies those on the host when the virtual machine
starts up, resumes after suspension or resumes on a new host after
migration. libvirt tears down the traffic filtering rules when the virtual
machine shuts down, suspends, or a VM is migrated to another host. It will
also be possible to modify the filtering rules while a virtual machine is
running. In this architecture we apply the firewall rules on the outside
of the virtual machines on the Linux host and make use of the fact that
virtual machines can be configured by libvirt to have their network
traffic pass through the host and the host exposes (tap) 'backend'
interfaces on which the firewall rules can be applied. The application of
the firewall rules is optional and those who do not want to introduce a
raw network throughput performance hit on their system due to the
evaluation of every packet passing through the filtering chains, do not
have to use these capabilities. An initial implementation would be done
for libvirt's Qemu support.
As stated above, the application of firewall rules on virtual machines
will require some form of XML description that lets the user choose what
type of filtering is to be performed. In effect the user needs to be able
to tell libvirt which ebtables and iptables rules to generate so that the
appropriate filtering can be done. We realize that ebtables and iptables
have lots of capabilities but think that we need to restrict which
capabilities can actually be 'reached' through this XML.
The following proposal is based on an XML as defined by the DMTF (
http://www.dmtf.org/standards/cim/cim_schema_v2230/CIM_Network.pdf, slide
10) with extensions for processing of ARP packets.It gives control over
the evaluation of Ethernet (MAC) frames, ARP packet data and IP header
information. A (draft) XML skeleton in this case could look as follows:
<FilterEntry>
<Action>DROP|ACCEPT</Action> <!-- from FilterEntry -->
<TrafficType>incoming [to VM]|outgoing [from VM]</TrafficType>
<Hdr8021Filter>
<HdrSrcMACAddr8021> </HdrSrcMACAddr8021>
<HdrSrcMACMask8021> </HdrSrcMACMask8021>
<HdrDestMACAddr8021> </HdrDestMACAddr8021>
<HdrDestMACMask8021> </HdrDestMACMask8021>
<HdrProtocolID8021> numeric and/or string?
</HdrProtocolID8021>
<HdrPriorityValue8021></HdrPriorityValue8021>
<HdrVLANID8021> </HdrVLANID8021>
</Hdr8021Filter>
<ARPFilter>
<HWType> </HWType>
<ProtocolType> </ProtocolType>
<OPCode> </OPCode>
<SrcMACAddr> </SrcMACAddr>
<SrcIPAddr> </SrcIPAddr>
<DestMACAddr> </DestMACAddr>
<DestIPAddr> </DestIPAddr>
</ARPFilter>
<IPHeadersFilter>
<HdrIPVersion> </HdrIPVersion>
<HdrSrcAddress> </HdrSrcAddress>
<HdrSrcMask> </HdrSrcMask>
<HdrDestAddress> </HdrDestAddress>
<HdrDestMask> </HdrDestMask>
<HdrProtocolID> numeric and/or string? </HdrProtocolID>
<HdrSrcPortStart> </HdrSrcPortStart>
<HdrSrcPortEnd> </HdrSrcPortEnd>
<HdrDestPortStart> </HdrDestPortStart>
<HdrDestPortEnd> </HdrDestPortEnd>
<HdrDSCP> </HdrDSCP>
</IPHeadersFilter>
</FilterEntry>
Since the ebtables and iptables command cannot accept all possible
parameters at the same time, only a certain subset of the above parameters
may be set for any given filter command. Higher level application writers
will likely use a library that lets them choose which features they would
want to have enforced, such as no-broadcast or no-multicast, enforcement
of MAC spoofing prevention or ARP poisoning prevention, which then
generates this lower level XML rules in the appropriate order of the
rules.
Further, we will introduce filter pools where a collection of the above
filter rules can be stored and referenced to by virtual machines'
individual interface. A reference to such a filter pool entry will be
given in the interface description and may look as in the following draft
XML:
<interface type='bridge'>
<source bridge='virbr0'/>
<script path='vif-bridge'/>
<firewall>
<reference profile='generic-layer2' ip_address='10.0.0.1'/>
<reference profile='VM-specific-layer3'/>
</firewall>
</interface>
The above XML has one reference to a generic layer2 filter template XML
that should be usable by multiple virtual machines but would need to be
customized with interface-specific parameters. In this case, the IP
address of the interface is explicitly provided in order to make the
filter XML template a concrete XML for the particular interface. The MAC
address of the interface is not explicitly provided since it will already
have been randomly generated by libvirt at the point when this layer2
filter XML needs to be converted into concrete ebtables commands/rules. We
still need to determine how the format of a template should look like,
though an idea would be to indicate a placeholder for a VM's MAC address
using THIS_MAC and similarly for the IP address with THIS_IP as
placeholder.
Further, we would introduce the management of filter 'pools'. Considering
existing functionality in libvirt and CLI commands for similar type of
management functionality, the following CLI commands would be added:
virsh nwfilter-create <file>
virsh nwfilter-destroy <profile name>
virsh nwfilter-list <options>
virsh nwfilter-dumpxml <profile name>
virsh nwfilter-update <filename> (performs an update on an existing
profile replacing all rules)
possibly also:
virsh nwfilter-edit <profile name>
virsh nwfilter-create-from <profile name>
Please let us know what you think of this proposal.
Regards
Stefan, Gerhard and Vivek
14 years, 10 months
[libvirt] [PATCH] qemudNetworkIfaceConnect: remove dead store
by Jim Meyering
clang reported this "dead store".
As you can see, just a few lines before
there's an identical assignment, so this may have been
an editing error (didn't dig).
As clang reports, that final assignment is a dead store,
since there is no following use of "errobj".
>From 92edbcf2ffa0dad25251723cd0749be2397a2321 Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering(a)redhat.com>
Date: Mon, 1 Mar 2010 15:59:42 +0100
Subject: [PATCH] qemudNetworkIfaceConnect: remove dead store
* src/qemu/qemu_conf.c (qemudNetworkIfaceConnect): Remove extraneous
virSaveLastError call, whose result was unused.
---
src/qemu/qemu_conf.c | 1 -
1 files changed, 0 insertions(+), 1 deletions(-)
diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index 1f8a9c3..eee6222 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -1520,11 +1520,10 @@ qemudNetworkIfaceConnect(virConnectPtr conn,
errobj = virSaveLastError();
virNetworkFree(network);
virSetError(errobj);
virFreeError(errobj);
- errobj = virSaveLastError();
if (fail)
return -1;
} else if (net->type == VIR_DOMAIN_NET_TYPE_BRIDGE) {
if (!(brname = strdup(net->data.bridge.brname))) {
--
1.7.0.1.414.g89213d
14 years, 10 months
[libvirt] [PATCH] udevEnumerateDevices: remove dead code
by Jim Meyering
Clang reported the dead store.
>From 0557e23ca2f5eb78ed9f260040895011785f670f Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering(a)redhat.com>
Date: Mon, 1 Mar 2010 16:14:35 +0100
Subject: [PATCH] udevEnumerateDevices: remove dead code
* src/node_device/node_device_udev.c (udevEnumerateDevices): Remove
unnecessary call to udev_list_entry_get_name.
---
src/node_device/node_device_udev.c | 4 +---
1 files changed, 1 insertions(+), 3 deletions(-)
diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_device_udev.c
index 68509f4..eee44c4 100644
--- a/src/node_device/node_device_udev.c
+++ b/src/node_device/node_device_udev.c
@@ -1,11 +1,11 @@
/*
* node_device_udev.c: node device enumeration - libudev implementation
*
- * Copyright (C) 2009 Red Hat
+ * Copyright (C) 2009-2010 Red Hat
*
* 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,
@@ -1333,30 +1333,28 @@ static int udevProcessDeviceListEntry(struct udev *udev,
}
static int udevEnumerateDevices(struct udev *udev)
{
struct udev_enumerate *udev_enumerate = NULL;
struct udev_list_entry *list_entry = NULL;
- const char *name = NULL;
int ret = 0;
udev_enumerate = udev_enumerate_new(udev);
ret = udev_enumerate_scan_devices(udev_enumerate);
if (0 != ret) {
VIR_ERROR("udev scan devices returned %d", ret);
goto out;
}
udev_list_entry_foreach(list_entry,
udev_enumerate_get_list_entry(udev_enumerate)) {
udevProcessDeviceListEntry(udev, list_entry);
- name = udev_list_entry_get_name(list_entry);
}
out:
udev_enumerate_unref(udev_enumerate);
return ret;
}
--
1.7.0.1.414.g89213d
14 years, 10 months
[libvirt] [PATCH] cmdPoolDiscoverSources: initialize earlier to avoid FP from clang
by Jim Meyering
This change hoists the initialization of srcSpec to the top,
to keep clang from reporting a false-positive used-uninitialized problem.
>From f487655124c887310be3bc82d7beae3cd47e7d21 Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering(a)redhat.com>
Date: Mon, 1 Mar 2010 15:41:15 +0100
Subject: [PATCH] cmdPoolDiscoverSources: initialize earlier to avoid FP from clang
* tools/virsh.c (cmdPoolDiscoverSources): Always initialize srcSpec.
Otherwise, clang would report that srcSpec could be used uninitialized
in the call to virConnectFindStoragePoolSources.
---
tools/virsh.c | 7 +++----
1 files changed, 3 insertions(+), 4 deletions(-)
diff --git a/tools/virsh.c b/tools/virsh.c
index 3b1011c..191e7ba 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -4431,17 +4431,16 @@ static const vshCmdOptDef opts_find_storage_pool_sources[] = {
static int
cmdPoolDiscoverSources(vshControl * ctl, const vshCmd * cmd ATTRIBUTE_UNUSED)
{
- char *type, *srcSpec, *srcSpecFile, *srcList;
+ char *type, *srcSpecFile, *srcList;
+ char *srcSpec = NULL;
int found;
type = vshCommandOptString(cmd, "type", &found);
if (!found)
return FALSE;
srcSpecFile = vshCommandOptString(cmd, "srcSpec", &found);
- if (!found) {
+ if (!found)
srcSpecFile = NULL;
- srcSpec = NULL;
- }
if (!vshConnectionUsability(ctl, ctl->conn, TRUE))
return FALSE;
--
1.7.0.1.414.g89213d
14 years, 10 months
[libvirt] [PATCH] qemu: avoid null dereference on failed migration
by Eric Blake
From: Eric Blake <eblake(a)redhat.com>
* src/qemu/qemu_monitor_text.c
(qemuMonitorTextGetMigrationStatus): Check for failed strchr, to
silence a coverity warning.
Signed-off-by: Eric Blake <eblake(a)redhat.com>
---
src/qemu/qemu_monitor_text.c | 5 +++++
1 files changed, 5 insertions(+), 0 deletions(-)
diff --git a/src/qemu/qemu_monitor_text.c b/src/qemu/qemu_monitor_text.c
index 62ffcc6..e7b4b1f 100644
--- a/src/qemu/qemu_monitor_text.c
+++ b/src/qemu/qemu_monitor_text.c
@@ -989,6 +989,11 @@ int qemuMonitorTextGetMigrationStatus(qemuMonitorPtr mon,
if ((tmp = strstr(reply, MIGRATION_PREFIX)) != NULL) {
tmp += strlen(MIGRATION_PREFIX);
end = strchr(tmp, '\r');
+ if (end == NULL) {
+ qemuReportError(VIR_ERR_INTERNAL_ERROR,
+ _("unexpected migration status in %s"), reply);
+ goto cleanup;
+ }
*end = '\0';
if ((*status = qemuMonitorMigrationStatusTypeFromString(tmp)) < 0) {
--
1.6.6.1
14 years, 10 months
[libvirt] [PATCH] Do not search xenstore for disk device IDs
by Jim Fehlig
Disk devices can be referenced by name in Xen, e.g. when modifying
their configuration or remvoving them. As such, don't search
xenstore for a device ID corresponding to the disk device. Instead,
search the disks contained in the domain definition and use the
disk's target name if found.
This approach allows removing a disk when domain is inactive. We
obviously can't search xenstore when the domain is inactive.
---
src/xen/xend_internal.c | 38 +++++++++++++++++++++++---------------
1 files changed, 23 insertions(+), 15 deletions(-)
diff --git a/src/xen/xend_internal.c b/src/xen/xend_internal.c
index 9d95291..d0d32e2 100644
--- a/src/xen/xend_internal.c
+++ b/src/xen/xend_internal.c
@@ -93,6 +93,7 @@ xenDaemonFormatSxprOnePCI(virConnectPtr conn,
static int
virDomainXMLDevID(virDomainPtr domain,
+ virDomainDefPtr domDef,
virDomainDeviceDefPtr dev,
char *class,
char *ref,
@@ -4212,7 +4213,7 @@ xenDaemonAttachDeviceFlags(virDomainPtr domain, const char *xml,
sexpr = virBufferContentAndReset(&buf);
- if (virDomainXMLDevID(domain, dev, class, ref, sizeof(ref))) {
+ if (virDomainXMLDevID(domain, def, dev, class, ref, sizeof(ref))) {
/* device doesn't exist, define it */
ret = xend_op(domain->conn, domain->name, "op", "device_create",
"config", sexpr, NULL);
@@ -4306,7 +4307,7 @@ xenDaemonDetachDeviceFlags(virDomainPtr domain, const char *xml,
def, xml, VIR_DOMAIN_XML_INACTIVE)))
goto cleanup;
- if (virDomainXMLDevID(domain, dev, class, ref, sizeof(ref)))
+ if (virDomainXMLDevID(domain, def, dev, class, ref, sizeof(ref)))
goto cleanup;
if (dev->type == VIR_DOMAIN_DEVICE_HOSTDEV) {
@@ -6048,6 +6049,7 @@ error:
*/
static int
virDomainXMLDevID(virDomainPtr domain,
+ virDomainDefPtr domDef,
virDomainDeviceDefPtr dev,
char *class,
char *ref,
@@ -6056,27 +6058,33 @@ virDomainXMLDevID(virDomainPtr domain,
xenUnifiedPrivatePtr priv = domain->conn->privateData;
char *xref;
char *tmp;
+ unsigned int i;
+ virDomainDiskDefPtr disk;
if (dev->type == VIR_DOMAIN_DEVICE_DISK) {
+ if (dev->data.disk->dst == NULL)
+ return -1;
if (dev->data.disk->driverName &&
STREQ(dev->data.disk->driverName, "tap"))
strcpy(class, "tap");
else
strcpy(class, "vbd");
- if (dev->data.disk->dst == NULL)
- return -1;
- xenUnifiedLock(priv);
- xref = xenStoreDomainGetDiskID(domain->conn, domain->id,
- dev->data.disk->dst);
- xenUnifiedUnlock(priv);
- if (xref == NULL)
- return -1;
-
- tmp = virStrcpy(ref, xref, ref_len);
- VIR_FREE(xref);
- if (tmp == NULL)
- return -1;
+ /* For disks, the device name can be used directly.
+ * If disk device exists in domain definintion,
+ * copy it to ref and return success.
+ */
+ for (i = 0; i < domDef->ndisks; i++) {
+ disk = domDef->disks[i];
+ if (STREQ(dev->data.disk->dst, disk->dst)) {
+ tmp = virStrcpy(ref, disk->dst, ref_len);
+ if (tmp == NULL)
+ return -1;
+ else
+ return 0;
+ }
+ }
+ return -1;
} else if (dev->type == VIR_DOMAIN_DEVICE_NET) {
char mac[30];
virDomainNetDefPtr def = dev->data.net;
--
1.6.0.2
14 years, 10 months
[libvirt] running libvirt on Xen Cloud Platform 0.7.1
by Gadi Naor
Hi,
I am trying to run libvirt daemon in Dom0 of Xen Cloud Platform 0.7.1.
For that purpose I downloaded the libvirt source files 0.7.6 and trying to build the libvirt rpm with XEN driver using the XCP DDK.
I am running into to many problems getting it done - so I was wondering whether this is supported or if anyone is using it in such way.
Thank You,
Gadi
_________________________________________________________________
Hotmail: Free, trusted and rich email service.
https://signup.live.com/signup.aspx?id=60969
14 years, 10 months
[libvirt] and for LXC?
by Mihamina Rakotomandimby
Manao ahoana, Hello, Bonjour,
Is there some plan/schedule to make libvirt LXC friendly?
Or is it already?
Misaotra, Thanks, Merci.
--
Architecte Informatique chez Blueline/Gulfsat:
Administration Systeme, Recherche & Developpement
+261 34 29 155 34 / +261 33 11 207 36
14 years, 10 months