[libvirt] driver level connection close event
by Nikolay Shirokovskiy
Notify of connection close event from parallels driver (possibly) wrapped in
the remote driver.
Discussion.
In 1 and 2 patch we forced to some decisions because we don't have a weak
reference mechanics.
1 patch.
-----------
virConnectCloseCallback is introduced because we can not reference the
connection object itself when setting a network layer callback because of how
connection close works.
A connection close procedure is next:
1. client closes connection
2. a this point nobody else referencing a connection and it is disposed
3. connection dispose unreferencing network connection
4. network connection disposes
Thus if we referece a connection in network close callback we never get step 2.
virConnectCloseCallback broke this cycle but at cost that clients MUST
unregister explicitly before closing connection. This is not good as this
unregistration is not really neaded. Client is not telling that it does not
want to receive events anymore but rather forced to obey some
implementation-driven rules.
2 patch.
-----------
We impose requirements on driver implementations which is fragile. Moreover we
again need to make explicit unregistrations. Implementation of domain events
illustrates this point. remoteDispatchConnectDomainEventRegister does not
reference NetClient and makes unregistration before NetClient is disposed but
drivers do not meet the formulated requirements. Object event system release
lock before delivering event for re-entrance purposes.
Shortly we have 2 undesired consequences here.
1. Mandatory unregistration.
2. Imposing multi-threading requirements.
Introduction of weak pointers could free us from these artifacts. Next weak
reference workflow illustrates this.
1. Take weak reference on object of interest before passing to party. This
doesn't break disposing mechanics as weak eference does not prevent from
disposing object. Object is disposed but memory is not freed yet if there are
weak references.
2. When callback is called we are safe to check if pointer dangling as we make
a weak reference before.
3. Release weak reference and this trigger memory freeing if there are no more
weak references.
daemon/libvirtd.h | 1 +
daemon/remote.c | 87 ++++++++++++++++++++++++++++++++
src/datatypes.c | 112 +++++++++++++++++++++++++++++++----------
src/datatypes.h | 21 ++++++--
src/driver-hypervisor.h | 12 +++++
src/libvirt-host.c | 79 ++++++++++--------------------
src/remote/remote_driver.c | 108 +++++++++++++++++++++++++++++++---------
src/remote/remote_protocol.x | 24 +++++++++-
src/remote_protocol-structs | 6 ++
src/vz/vz_driver.c | 26 ++++++++++
src/vz/vz_sdk.c | 32 +++++++++++-
src/vz/vz_utils.h | 3 +
12 files changed, 396 insertions(+), 115 deletions(-)
9 years, 10 months
[libvirt] [PATCH] qemu: fix wrong remove guest cfg if migrate fail
by Luyao Huang
If we get fail in qemuMigrationPrepareAny, we forget
check if the vm is persistent then always call
qemuDomainRemoveInactive to clean the inactive settings.
Add a check to avoid this. This issue was introduce in
commit 540c339.
Signed-off-by: Luyao Huang <lhuang(a)redhat.com>
---
src/qemu/qemu_migration.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index 47d49cd..a57a177 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -3432,7 +3432,8 @@ qemuMigrationPrepareAny(virQEMUDriverPtr driver,
VIR_FREE(priv->origname);
virPortAllocatorRelease(driver->migrationPorts, priv->nbdPort);
priv->nbdPort = 0;
- qemuDomainRemoveInactive(driver, vm);
+ if (!vm->persistent)
+ qemuDomainRemoveInactive(driver, vm);
}
virDomainObjEndAPI(&vm);
if (event)
--
1.8.3.1
9 years, 10 months
[libvirt] [PATCH] virt-xml-validate: Allow input to be read from stdin
by Johannes Holmberg
---
Hello,
I often find myself wanting to validate a domain xml without having
to save it to a file, so I've updated virt-xml-validate to support
the standard practice of reading from stdin when "-" is given as the
input file.
Of course, the validation is multipass so there still needs to be a
temporary file but I think it makes sense to hide this complexity in
virt-xml-validate and not force it onto the user.
/Johannes
tools/virt-xml-validate.in | 53 +++++++++++++++++++++++++++++++++-------------
1 file changed, 38 insertions(+), 15 deletions(-)
diff --git a/tools/virt-xml-validate.in b/tools/virt-xml-validate.in
index a04fa06..8807f8d 100644
--- a/tools/virt-xml-validate.in
+++ b/tools/virt-xml-validate.in
@@ -17,6 +17,16 @@
set -e
+TMPFILE=
+
+cleanup() {
+ if [ $TMPFILE ]; then
+ rm -f $TMPFILE
+ fi
+}
+
+trap cleanup EXIT
+
case $1 in
-h | --h | --he | --hel | --help)
cat <<EOF
@@ -35,7 +45,7 @@ $0 (libvirt) @VERSION@
EOF
exit ;;
--) shift ;;
- -*)
+ -?*)
echo "$0: unrecognized option '$1'" >&2
exit 1 ;;
esac
@@ -43,18 +53,27 @@ esac
XMLFILE="$1"
TYPE="$2"
-if [ -z "$XMLFILE" ]; then
- echo "syntax: $0 XMLFILE [TYPE]" >&2
- exit 1
-fi
-
-if [ ! -f "$XMLFILE" ]; then
- echo "$0: document $XMLFILE does not exist" >&2
- exit 2
+if [ "$XMLFILE" = "-" ]; then
+ TMPFILE=`mktemp --tmpdir virt-xml.XXXX`
+ cat > $TMPFILE
+else
+ if [ -z "$XMLFILE" ]; then
+ echo "syntax: $0 XMLFILE [TYPE]" >&2
+ exit 1
+ fi
+
+ if [ ! -f "$XMLFILE" ]; then
+ echo "$0: document $XMLFILE does not exist" >&2
+ exit 2
+ fi
fi
if [ -z "$TYPE" ]; then
- ROOT=`xmllint --stream --debug "$XMLFILE" 2>/dev/null | grep "^0 1 " | awk '{ print $3 }'`
+ if [ $TMPFILE ]; then
+ ROOT=`cat "$TMPFILE" | xmllint --stream --debug - 2>/dev/null | grep "^0 1 " | awk '{ print $3 }'`
+ else
+ ROOT=`xmllint --stream --debug "$XMLFILE" 2>/dev/null | grep "^0 1 " | awk '{ print $3 }'`
+ fi
case "$ROOT" in
*domainsnapshot*) # Must come first, since *domain* is a substring
TYPE="domainsnapshot"
@@ -99,8 +118,11 @@ if [ ! -f "$SCHEMA" ]; then
exit 4
fi
-xmllint --noout --relaxng "$SCHEMA" "$XMLFILE"
-
+if [ $TMPFILE ]; then
+ cat "$TMPFILE" | xmllint --noout --relaxng "$SCHEMA" -
+else
+ xmllint --noout --relaxng "$SCHEMA" "$XMLFILE"
+fi
exit
: <<=cut
@@ -119,9 +141,10 @@ exit
Validates a libvirt XML for compliance with the published schema.
The first compulsory argument is the path to the XML file to be
-validated. The optional second argument is the name of the schema
-to validate against. If omitted, the schema name will be inferred
-from the name of the root element in the XML document.
+validated (or - to read the XML from standard input). The optional
+second argument is the name of the schema to validate against. If
+omitted, the schema name will be inferred from the name of the root
+element in the XML document.
Valid schema names currently include
--
1.9.1
9 years, 10 months
[libvirt] [PATCH] qemu:conf: introduce a function to delete vcpu sched
by Luyao Huang
https://bugzilla.redhat.com/show_bug.cgi?id=1235180
We have API allow vpu to be deleted, but an vcpu may be
included in some domain vcpu sched, so add a new API to
allow removing an iothread from some entry.
Split the virDomainIOThreadSchedDelId to reuse some code.
Signed-off-by: Luyao Huang <lhuang(a)redhat.com>
---
src/conf/domain_conf.c | 48 ++++++++++++++++++++++++++++++++++--------------
src/conf/domain_conf.h | 1 +
src/libvirt_private.syms | 1 +
src/qemu/qemu_driver.c | 6 ++++--
4 files changed, 40 insertions(+), 16 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 183e66c..7a464a6 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -17996,29 +17996,49 @@ virDomainIOThreadIDDel(virDomainDefPtr def,
}
}
-void
-virDomainIOThreadSchedDelId(virDomainDefPtr def,
- unsigned int iothreadid)
+static void
+virDomainThreadSchedDelId(virDomainThreadSchedParamPtr *threadsched,
+ size_t *nthreadsched,
+ unsigned int id)
{
size_t i;
- if (!def->cputune.iothreadsched || !def->cputune.niothreadsched)
- return;
-
- for (i = 0; i < def->cputune.niothreadsched; i++) {
- if (virBitmapIsBitSet(def->cputune.iothreadsched[i].ids, iothreadid)) {
- ignore_value(virBitmapClearBit(def->cputune.iothreadsched[i].ids,
- iothreadid));
- if (virBitmapIsAllClear(def->cputune.iothreadsched[i].ids)) {
- virBitmapFree(def->cputune.iothreadsched[i].ids);
- VIR_DELETE_ELEMENT(def->cputune.iothreadsched, i,
- def->cputune.niothreadsched);
+ for (i = 0; i < *nthreadsched; i++) {
+ if (virBitmapIsBitSet((*threadsched)[i].ids, id)) {
+ ignore_value(virBitmapClearBit((*threadsched)[i].ids, id));
+ if (virBitmapIsAllClear((*threadsched)[i].ids)) {
+ virBitmapFree((*threadsched)[i].ids);
+ VIR_DELETE_ELEMENT((*threadsched), i, *nthreadsched);
}
return;
}
}
}
+void
+virDomainIOThreadSchedDelId(virDomainDefPtr def,
+ unsigned int iothreadid)
+{
+ if (!def->cputune.iothreadsched || !def->cputune.niothreadsched)
+ return;
+
+ virDomainThreadSchedDelId(&def->cputune.iothreadsched,
+ &def->cputune.niothreadsched,
+ iothreadid);
+}
+
+void
+virDomainVcpuSchedDelId(virDomainDefPtr def,
+ unsigned int vcpuid)
+{
+ if (!def->cputune.vcpusched || !def->cputune.nvcpusched)
+ return;
+
+ virDomainThreadSchedDelId(&def->cputune.vcpusched,
+ &def->cputune.nvcpusched,
+ vcpuid);
+}
+
virDomainPinDefPtr
virDomainPinFind(virDomainPinDefPtr *def,
int npin,
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index c96a6e4..a74dbc9 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -2662,6 +2662,7 @@ virDomainIOThreadIDDefPtr virDomainIOThreadIDAdd(virDomainDefPtr def,
unsigned int iothread_id);
void virDomainIOThreadIDDel(virDomainDefPtr def, unsigned int iothread_id);
void virDomainIOThreadSchedDelId(virDomainDefPtr def, unsigned int iothread_id);
+void virDomainVcpuSchedDelId(virDomainDefPtr def, unsigned int vcpuid);
unsigned int virDomainDefFormatConvertXMLFlags(unsigned int flags);
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 1566d11..169d641 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -479,6 +479,7 @@ virDomainTPMBackendTypeToString;
virDomainTPMDefFree;
virDomainTPMModelTypeFromString;
virDomainTPMModelTypeToString;
+virDomainVcpuSchedDelId;
virDomainVideoDefaultRAM;
virDomainVideoDefaultType;
virDomainVideoDefFree;
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index c1373de..245443c 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -4966,12 +4966,14 @@ qemuDomainSetVcpusFlags(virDomainPtr dom, unsigned int nvcpus,
}
if (persistentDef) {
- /* remove vcpupin entries for vcpus that were unplugged */
+ /* remove vcpupin and vcpusched entries for vcpus that were unplugged */
if (nvcpus < persistentDef->vcpus) {
- for (i = persistentDef->vcpus - 1; i >= nvcpus; i--)
+ for (i = persistentDef->vcpus - 1; i >= nvcpus; i--) {
virDomainPinDel(&persistentDef->cputune.vcpupin,
&persistentDef->cputune.nvcpupin,
i);
+ virDomainVcpuSchedDelId(persistentDef, i);
+ }
}
if (flags & VIR_DOMAIN_VCPU_MAXIMUM) {
--
1.8.3.1
9 years, 10 months
[libvirt] [PATCH] qemu: check hostdev address type
by Ján Tomko
For USB and SCSI hostdevs, we passed the invalid address to QEMU.
Report an error earlier.
PCI hostdevs check the address type when parsing the XML.
https://bugzilla.redhat.com/show_bug.cgi?id=1225339
---
src/qemu/qemu_command.c | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 3886b4f..a4853ab 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -10572,7 +10572,12 @@ qemuBuildCommandLine(virConnectPtr conn,
/* USB */
if (hostdev->mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS &&
hostdev->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB) {
-
+ if (hostdev->info->type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE &&
+ hostdev->info->type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_USB) {
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("USB host devices must use 'usb' address type"));
+ goto error;
+ }
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE)) {
virCommandAddArg(cmd, "-device");
if (!(devstr = qemuBuildUSBHostdevDevStr(def, hostdev, qemuCaps)))
@@ -10644,6 +10649,12 @@ qemuBuildCommandLine(virConnectPtr conn,
/* SCSI */
if (hostdev->mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS &&
hostdev->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI) {
+ if (hostdev->info->type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE &&
+ hostdev->info->type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DRIVE) {
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("SCSI host devices must use 'drive' address type"));
+ goto error;
+ }
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DRIVE) &&
virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE) &&
virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_SCSI_GENERIC)) {
--
2.3.6
9 years, 10 months
[libvirt] [PATCH] test: Refactor vcpu pinning and vcpu info retrieval
by Peter Krempa
Drop internal data structures and use the proper fields in virDomainDef.
This allows to greatly simplify the code and allows to remove the
private data structure that was holding just redundant data.
This patch also fixes the bogous output where we'd report that a fresh
VM without vCPU pinning would not run on all vcpus.
---
This applies on top of [PATCH 0/8] Test driver refactors and fixes:
src/test/test_driver.c | 224 +++++++++++--------------------------------------
1 file changed, 49 insertions(+), 175 deletions(-)
diff --git a/src/test/test_driver.c b/src/test/test_driver.c
index 9e617a2..f17d353 100644
--- a/src/test/test_driver.c
+++ b/src/test/test_driver.c
@@ -64,14 +64,6 @@
VIR_LOG_INIT("test.test_driver");
-/* Driver specific info to carry with a domain */
-struct _testDomainObjPrivate {
- virVcpuInfoPtr vcpu_infos;
-
- unsigned char *cpumaps;
-};
-typedef struct _testDomainObjPrivate testDomainObjPrivate;
-typedef struct _testDomainObjPrivate *testDomainObjPrivatePtr;
#define MAX_CPUS 128
@@ -170,25 +162,6 @@ testObjectEventQueueUnlocked(testConnPtr driver,
testDriverUnlock(driver);
}
-static void *testDomainObjPrivateAlloc(void)
-{
- testDomainObjPrivatePtr priv;
-
- if (VIR_ALLOC(priv) < 0)
- return NULL;
-
- return priv;
-}
-
-static void testDomainObjPrivateFree(void *data)
-{
- testDomainObjPrivatePtr priv = data;
-
- VIR_FREE(priv->vcpu_infos);
- VIR_FREE(priv->cpumaps);
- VIR_FREE(priv);
-}
-
#define TEST_NAMESPACE_HREF "http://libvirt.org/schemas/domain/test/1.0"
typedef struct _testDomainNamespaceDef testDomainNamespaceDef;
@@ -313,18 +286,13 @@ testDomainDefNamespaceParse(xmlDocPtr xml ATTRIBUTE_UNUSED,
static virDomainXMLOptionPtr
testBuildXMLConfig(void)
{
- virDomainXMLPrivateDataCallbacks priv = {
- .alloc = testDomainObjPrivateAlloc,
- .free = testDomainObjPrivateFree
- };
-
/* All our XML extensions are input only, so we only need to parse */
virDomainXMLNamespace ns = {
.parse = testDomainDefNamespaceParse,
.free = testDomainDefNamespaceFree,
};
- return virDomainXMLOptionNew(NULL, &priv, &ns);
+ return virDomainXMLOptionNew(NULL, NULL, &ns);
}
@@ -580,95 +548,6 @@ testDomainGenerateIfnames(virDomainDefPtr domdef)
return 0;
}
-/* Helper to update info for a single VCPU */
-static int
-testDomainUpdateVCPU(virDomainObjPtr dom,
- int vcpu,
- int maplen,
- int maxcpu)
-{
- testDomainObjPrivatePtr privdata = dom->privateData;
- virVcpuInfoPtr info = &privdata->vcpu_infos[vcpu];
- unsigned char *cpumap = VIR_GET_CPUMAP(privdata->cpumaps, maplen, vcpu);
- size_t j;
- bool cpu;
-
- memset(info, 0, sizeof(virVcpuInfo));
- memset(cpumap, 0, maplen);
-
- info->number = vcpu;
- info->state = VIR_VCPU_RUNNING;
- info->cpuTime = 5000000;
- info->cpu = 0;
-
- if (dom->def->cpumask) {
- for (j = 0; j < maxcpu && j < VIR_DOMAIN_CPUMASK_LEN; ++j) {
- if (virBitmapGetBit(dom->def->cpumask, j, &cpu) < 0)
- return -1;
- if (cpu) {
- VIR_USE_CPU(cpumap, j);
- info->cpu = j;
- }
- }
- } else {
- for (j = 0; j < maxcpu; ++j) {
- if ((j % 3) == 0) {
- /* Mark of every third CPU as usable */
- VIR_USE_CPU(cpumap, j);
- info->cpu = j;
- }
- }
- }
-
- return 0;
-}
-
-/*
- * Update domain VCPU amount and info
- *
- * @conn: virConnectPtr
- * @dom : domain needing updates
- * @nvcpus: New amount of vcpus for the domain
- * @clear_all: If true, rebuild info for ALL vcpus, not just newly added vcpus
- */
-static int
-testDomainUpdateVCPUs(testConnPtr privconn,
- virDomainObjPtr dom,
- int nvcpus,
- unsigned int clear_all)
-{
- testDomainObjPrivatePtr privdata = dom->privateData;
- size_t i;
- int ret = -1;
- int cpumaplen, maxcpu;
-
- maxcpu = VIR_NODEINFO_MAXCPUS(privconn->nodeInfo);
- cpumaplen = VIR_CPU_MAPLEN(maxcpu);
-
- if (VIR_REALLOC_N(privdata->vcpu_infos, nvcpus) < 0)
- goto cleanup;
-
- if (VIR_REALLOC_N(privdata->cpumaps, nvcpus * cpumaplen) < 0)
- goto cleanup;
-
- /* Set running VCPU and cpumap state */
- if (clear_all) {
- for (i = 0; i < nvcpus; ++i)
- if (testDomainUpdateVCPU(dom, i, cpumaplen, maxcpu) < 0)
- goto cleanup;
-
- } else if (nvcpus > dom->def->vcpus) {
- /* VCPU amount has grown, populate info for the new vcpus */
- for (i = dom->def->vcpus; i < nvcpus; ++i)
- if (testDomainUpdateVCPU(dom, i, cpumaplen, maxcpu) < 0)
- goto cleanup;
- }
-
- dom->def->vcpus = nvcpus;
- ret = 0;
- cleanup:
- return ret;
-}
static void
testDomainShutdownState(virDomainPtr domain,
@@ -695,9 +574,6 @@ testDomainStartState(testConnPtr privconn,
{
int ret = -1;
- if (testDomainUpdateVCPUs(privconn, dom, dom->def->vcpus, 1) < 0)
- goto cleanup;
-
virDomainObjSetState(dom, VIR_DOMAIN_RUNNING, reason);
dom->def->id = privconn->nextDomID++;
@@ -2507,7 +2383,6 @@ static int
testDomainSetVcpusFlags(virDomainPtr domain, unsigned int nrCpus,
unsigned int flags)
{
- testConnPtr privconn = domain->conn->privateData;
virDomainObjPtr privdom = NULL;
virDomainDefPtr def;
virDomainDefPtr persistentDef;
@@ -2544,9 +2419,8 @@ testDomainSetVcpusFlags(virDomainPtr domain, unsigned int nrCpus,
goto cleanup;
}
- if (def &&
- testDomainUpdateVCPUs(privconn, privdom, nrCpus, 0) < 0)
- goto cleanup;
+ if (def)
+ def->vcpus = nrCpus;
if (persistentDef) {
if (flags & VIR_DOMAIN_VCPU_MAXIMUM) {
@@ -2578,13 +2452,14 @@ static int testDomainGetVcpus(virDomainPtr domain,
int maplen)
{
testConnPtr privconn = domain->conn->privateData;
- testDomainObjPrivatePtr privdomdata;
virDomainObjPtr privdom;
+ virDomainDefPtr def;
size_t i;
- int v, maxcpu, hostcpus;
+ int maxcpu, hostcpus;
int ret = -1;
struct timeval tv;
unsigned long long statbase;
+ virBitmapPtr allcpumap;
if (!(privdom = testDomObjFromDomain(domain)))
return -1;
@@ -2595,7 +2470,7 @@ static int testDomainGetVcpus(virDomainPtr domain,
goto cleanup;
}
- privdomdata = privdom->privateData;
+ def = privdom->def;
if (gettimeofday(&tv, NULL) < 0) {
virReportSystemError(errno,
@@ -2605,45 +2480,47 @@ static int testDomainGetVcpus(virDomainPtr domain,
statbase = (tv.tv_sec * 1000UL * 1000UL) + tv.tv_usec;
-
hostcpus = VIR_NODEINFO_MAXCPUS(privconn->nodeInfo);
maxcpu = maplen * 8;
if (maxcpu > hostcpus)
maxcpu = hostcpus;
+ if (!(allcpumap = virBitmapNew(hostcpus)))
+ goto cleanup;
+
+ virBitmapSetAll(allcpumap);
+
/* Clamp to actual number of vcpus */
if (maxinfo > privdom->def->vcpus)
maxinfo = privdom->def->vcpus;
- /* Populate virVcpuInfo structures */
- if (info != NULL) {
- memset(info, 0, sizeof(*info) * maxinfo);
+ memset(info, 0, sizeof(*info) * maxinfo);
+ memset(cpumaps, 0, maxinfo * maplen);
- for (i = 0; i < maxinfo; i++) {
- virVcpuInfo privinfo = privdomdata->vcpu_infos[i];
+ for (i = 0; i < maxinfo; i++) {
+ virDomainPinDefPtr pininfo;
+ virBitmapPtr bitmap = NULL;
- info[i].number = privinfo.number;
- info[i].state = privinfo.state;
- info[i].cpu = privinfo.cpu;
+ pininfo = virDomainPinFind(def->cputune.vcpupin,
+ def->cputune.nvcpupin,
+ i);
- /* Fake an increasing cpu time value */
- info[i].cpuTime = statbase / 10;
- }
- }
+ if (pininfo && pininfo->cpumask)
+ bitmap = pininfo->cpumask;
+ else if (def->cpumask)
+ bitmap = def->cpumask;
+ else
+ bitmap = allcpumap;
- /* Populate cpumaps */
- if (cpumaps != NULL) {
- int privmaplen = VIR_CPU_MAPLEN(hostcpus);
- memset(cpumaps, 0, maplen * maxinfo);
+ if (cpumaps)
+ virBitmapToDataBuf(bitmap, VIR_GET_CPUMAP(cpumaps, maplen, i), maplen);
- for (v = 0; v < maxinfo; v++) {
- unsigned char *cpumap = VIR_GET_CPUMAP(cpumaps, maplen, v);
+ info[i].number = i;
+ info[i].state = VIR_VCPU_RUNNING;
+ info[i].cpu = virBitmapLastSetBit(bitmap);
- for (i = 0; i < maxcpu; i++) {
- if (VIR_CPU_USABLE(privdomdata->cpumaps, privmaplen, v, i))
- VIR_USE_CPU(cpumap, i);
- }
- }
+ /* Fake an increasing cpu time value */
+ info[i].cpuTime = statbase / 10;
}
ret = maxinfo;
@@ -2657,17 +2534,15 @@ static int testDomainPinVcpu(virDomainPtr domain,
unsigned char *cpumap,
int maplen)
{
- testConnPtr privconn = domain->conn->privateData;
- testDomainObjPrivatePtr privdomdata;
virDomainObjPtr privdom;
- unsigned char *privcpumap;
- size_t i;
- int maxcpu, hostcpus, privmaplen;
+ virDomainDefPtr def;
int ret = -1;
if (!(privdom = testDomObjFromDomain(domain)))
return -1;
+ def = privdom->def;
+
if (!virDomainObjIsActive(privdom)) {
virReportError(VIR_ERR_OPERATION_INVALID,
"%s", _("cannot pin vcpus on an inactive domain"));
@@ -2680,20 +2555,19 @@ static int testDomainPinVcpu(virDomainPtr domain,
goto cleanup;
}
- privdomdata = privdom->privateData;
- hostcpus = VIR_NODEINFO_MAXCPUS(privconn->nodeInfo);
- privmaplen = VIR_CPU_MAPLEN(hostcpus);
-
- maxcpu = maplen * 8;
- if (maxcpu > hostcpus)
- maxcpu = hostcpus;
-
- privcpumap = VIR_GET_CPUMAP(privdomdata->cpumaps, privmaplen, vcpu);
- memset(privcpumap, 0, privmaplen);
-
- for (i = 0; i < maxcpu; i++) {
- if (VIR_CPU_USABLE(cpumap, maplen, 0, i))
- VIR_USE_CPU(privcpumap, i);
+ if (!def->cputune.vcpupin) {
+ if (VIR_ALLOC(def->cputune.vcpupin) < 0)
+ goto cleanup;
+ def->cputune.nvcpupin = 0;
+ }
+ if (virDomainPinAdd(&def->cputune.vcpupin,
+ &def->cputune.nvcpupin,
+ cpumap,
+ maplen,
+ vcpu) < 0) {
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("failed to update or add vcpupin"));
+ goto cleanup;
}
ret = 0;
--
2.4.1
9 years, 10 months
[libvirt] [PATCH] vz: fix syntax-check errors
by Dmitry Guryanov
Remove braces around single-statement blocks in vz_sdk.c
Signed-off-by: Dmitry Guryanov <dguryanov(a)parallels.com>
---
src/vz/vz_sdk.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/src/vz/vz_sdk.c b/src/vz/vz_sdk.c
index dea6e37..1a3aa87 100644
--- a/src/vz/vz_sdk.c
+++ b/src/vz/vz_sdk.c
@@ -2929,9 +2929,8 @@ int prlsdkAttachNet(virDomainObjPtr dom,
ret = prlsdkAddNet(privdom->sdkdom, privconn, net, IS_CT(dom->def));
if (ret == 0) {
job = PrlVm_CommitEx(privdom->sdkdom, PVCF_DETACH_HDD_BUNDLE);
- if (PRL_FAILED(waitJob(job))) {
+ if (PRL_FAILED(waitJob(job)))
return -1;
- }
}
return ret;
@@ -3027,9 +3026,8 @@ int prlsdkDetachNet(virDomainObjPtr dom,
ret = prlsdkDelNetAdapter(privdom->sdkdom, idx);
if (ret == 0) {
job = PrlVm_CommitEx(privdom->sdkdom, PVCF_DETACH_HDD_BUNDLE);
- if (PRL_FAILED(waitJob(job))) {
+ if (PRL_FAILED(waitJob(job)))
return -1;
- }
}
return ret;
--
2.1.0
9 years, 10 months
[libvirt] [PATCH v2] vz: implementation of attach/detach network devices
by Mikhail Feoktistov
Changes from v1
Remove "cleanup" label and "goto" operator from prlsdkAttachNet() and prlsdkDetachNet()
Replace it with "return" operator.
Rename netMac variable to expectedMac in prlsdkGetNetIndex()
Move prlsdkGetNetIndex() call after PrlVm_BeginEdit call in prlsdkDetachNet() function.
Mikhail Feoktistov (1):
vz: implementation of attach/detach network devices
9 years, 10 months
[libvirt] [sandbox PATCH 00/10] Patches for libvirt-sandbox
by Eren Yagdiran
Hello,
These patches provide disk support for libvirt-sandbox.
Implemented '--disk' parameter will be useful when integrating Docker image support for libvirt-sandbox.
--Main diffs compared to previous patches.
Since many hypervisors, including kvm, will not even honour requested
names for disk devices we link each device under /dev/disk/by-tag
e.g /dev/disk/by-tag/foobar -> /dev/sda
We populate disks.cfg with tag to device mapping when we build the sandbox.
After that, in each init-process {Common,Qemu}, we basically read the configuration
and populate the right symlinks under /dev/disk/by-tag
The common functions for modifying directories are moved under Init-util. {Common,Qemu} inits are using them.
Cédric Bosdonnat (2):
Add gvir_sandbox_config_has_disks function
qemu: use devtmpfs rather than tmpfs to auto-populate /dev
Eren Yagdiran (8):
Add an utility function for guessing filetype from file extension
Add configuration object for disk support
Add disk parameter to virt-sandbox
Add disk support to the container builder
Add disk support to machine builder
Init-util : Common directory functions for init-common and init-qemu
Common-init: Building symlink from disks.cfg
Common-builder: /dev/disk/by-tag/thetag to /dev/vdN
bin/virt-sandbox.c | 37 +++
libvirt-sandbox/Makefile.am | 7 +-
.../libvirt-sandbox-builder-container.c | 36 ++-
libvirt-sandbox/libvirt-sandbox-builder-machine.c | 44 ++-
libvirt-sandbox/libvirt-sandbox-builder.c | 73 ++++-
libvirt-sandbox/libvirt-sandbox-config-disk.c | 274 +++++++++++++++++++
libvirt-sandbox/libvirt-sandbox-config-disk.h | 82 ++++++
libvirt-sandbox/libvirt-sandbox-config.c | 300 +++++++++++++++++++++
libvirt-sandbox/libvirt-sandbox-config.h | 11 +
libvirt-sandbox/libvirt-sandbox-init-common.c | 51 +++-
libvirt-sandbox/libvirt-sandbox-init-qemu.c | 151 ++---------
libvirt-sandbox/libvirt-sandbox-init-util.c | 58 ++++
libvirt-sandbox/libvirt-sandbox-init-util.h | 41 +++
libvirt-sandbox/libvirt-sandbox-util.c | 72 +++++
libvirt-sandbox/libvirt-sandbox-util.h | 5 +
libvirt-sandbox/libvirt-sandbox.h | 1 +
libvirt-sandbox/libvirt-sandbox.sym | 5 +
libvirt-sandbox/tests/test-config.c | 11 +
po/POTFILES.in | 1 +
19 files changed, 1111 insertions(+), 149 deletions(-)
create mode 100644 libvirt-sandbox/libvirt-sandbox-config-disk.c
create mode 100644 libvirt-sandbox/libvirt-sandbox-config-disk.h
create mode 100644 libvirt-sandbox/libvirt-sandbox-init-util.c
create mode 100644 libvirt-sandbox/libvirt-sandbox-init-util.h
create mode 100644 libvirt-sandbox/libvirt-sandbox-util.c
--
2.1.0
9 years, 10 months