[libvirt] RFC: API to report guest IP address(es)
by Michal Privoznik
Hi,
Now we have qemu guest agent it is possible for us to:
1) extend guest agent to report IP addresses (not trivial among OSes).
2) Write API which will report these to mgmt application.
One thing that I am not sure about and would like you to ask is:
how should the API look like?
In addition, we have this nwfilter which already learns host interfaces
address (yeah, only one per interface).
What scenarios are we facing here?
1) It is impossible (in general) to tie guest interface with the host
interface because guest can change MAC address of any interface and
this change is not propagated to the outside world. Therefore vnet1 can
be eth0 or eth1 or even hello_i_am_funky_interface99.
2) Guest can create virtual interfaces within itself and therefore
create a totally different structure than observed from outside, e.g.
bonding.
3) Interface can have multiple addresses or even none.
Therefore I lean to something like:
int virDomainGetIPAddresses(virDomainPtr dom, char **addr[], int
*addr_size);
That is - simply return an array of IPs in string format (yes, allocated
by us) and leave mgmt application to decide what to do with that.
Any thoughts?
12 years, 8 months
[libvirt] [PATCH] conf: small changes to comments in virDomainDeviceInfo
by Laine Stump
romfile wasn't mentioned in the comment, and the fact that rombar is
now supported for network interfaces also wasn't there.
Pushed under the trivial rule.
---
src/conf/domain_conf.h | 6 ++++--
1 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 0a2795d..8bb21cf 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -167,10 +167,12 @@ struct _virDomainDeviceInfo {
union {
virDomainDeviceUSBMaster usb;
} master;
- /* rombar is only used for pci hostdev devices, and bootIndex only
- * for disk, network interface, and hostdev devices */
+ /* rombar and romfile are only used for pci hostdev and network
+ * devices. */
int rombar; /* enum virDomainPciRombarMode */
char *romfile;
+ /* bootIndex is only user for disk, network interface, and
+ * hostdev devices. */
int bootIndex;
};
--
1.7.7.6
12 years, 8 months
[libvirt] [PATCH] python: Correct arguments number for migrateSetMaxSpeed
by Osier Yang
The API definition accepts "flags" argument, however, the
implementation ignores it, though "flags" is unused currently,
we should expose it instead of hard coding, the API
implementation inside hypervisor driver is responsible to check
if the passed "flags" is valid.
---
python/libvirt-override.c | 6 ++++--
1 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/python/libvirt-override.c b/python/libvirt-override.c
index 33a841d..2c6e7cf 100644
--- a/python/libvirt-override.c
+++ b/python/libvirt-override.c
@@ -5062,14 +5062,16 @@ libvirt_virDomainMigrateGetMaxSpeed(PyObject *self ATTRIBUTE_UNUSED, PyObject *a
unsigned long bandwidth;
virDomainPtr domain;
PyObject *pyobj_domain;
+ unsigned int flags = 0;
- if (!PyArg_ParseTuple(args, (char *)"O:virDomainMigrateGetMaxSpeed", &pyobj_domain))
+ if (!PyArg_ParseTuple(args, (char *)"Oi:virDomainMigrateGetMaxSpeed",
+ &pyobj_domain, &flags))
return(NULL);
domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain);
LIBVIRT_BEGIN_ALLOW_THREADS;
- c_retval = virDomainMigrateGetMaxSpeed(domain, &bandwidth, 0);
+ c_retval = virDomainMigrateGetMaxSpeed(domain, &bandwidth, flags);
LIBVIRT_END_ALLOW_THREADS;
if (c_retval < 0)
--
1.7.7.3
12 years, 8 months
[libvirt] [PATCH] docs: fix typo in python bindings
by Eric Blake
* docs/python.html.in: Class is virConnect, not virConn.
---
Pushing this under the trivial rule.
docs/python.html.in | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/docs/python.html.in b/docs/python.html.in
index a8c972e..e7538a4 100644
--- a/docs/python.html.in
+++ b/docs/python.html.in
@@ -20,7 +20,7 @@ lower case, for example the C functions:</p>
</p>
<p>become</p>
<p>
- <code>virConn::numOfDomains(self)</code>
+ <code>virConnect::numOfDomains(self)</code>
</p>
<p>
<code>virDomain::setMaxMemory(self, memory)</code>
--
1.7.7.6
12 years, 8 months
[libvirt] [PATCH] cgroup:fix bug to keep --device-weights value persistent
by Guannan Ren
src/qemu/qemu_driver.c
When run "virsh blkiotune dom --device-weights /dev/sda,400 --config"
it couldn't be persistent after dom restart.
The patch fix it.
---
src/qemu/qemu_driver.c | 53 ++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 51 insertions(+), 2 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index d66140b..1a53088 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -5975,9 +5975,13 @@ qemuDomainMergeDeviceWeights(virBlkioDeviceWeightPtr *def, size_t *def_size,
virReportOOMError();
return -1;
}
- (*def)[*def_size - 1].path = dw->path;
+ (*def)[*def_size - 1].path = strdup(dw->path);
+ if (!(*def)[*def_size - 1].path) {
+ virReportOOMError();
+ return -1;
+ }
+
(*def)[*def_size - 1].weight = dw->weight;
- dw->path = NULL;
}
}
@@ -5985,6 +5989,46 @@ qemuDomainMergeDeviceWeights(virBlkioDeviceWeightPtr *def, size_t *def_size,
}
static int
+qemuDomainiDefineDeviceWeights(virDomainDefPtr persistentDef,
+ virBlkioDeviceWeightPtr devices, size_t ndevices)
+{
+ int i;
+ virBlkioDeviceWeightPtr dw, result = NULL;
+
+ if (!persistentDef->blkio.devices) {
+ if (VIR_ALLOC_N(result, ndevices) < 0) {
+ virReportOOMError();
+ goto cleanup;
+ }
+
+ for (i = 0; i < ndevices; i++) {
+ dw = &devices[i];
+ result[i].path = strdup(dw->path);
+ if (!result[i].path) {
+ virReportOOMError();
+ goto cleanup;
+ }
+ result[i].weight = dw->weight;
+ }
+
+ persistentDef->blkio.devices = result;
+ } else {
+ if (qemuDomainMergeDeviceWeights(&persistentDef->blkio.devices,
+ &persistentDef->blkio.ndevices,
+ devices, ndevices) < 0)
+ return -1;
+ }
+
+ persistentDef->blkio.ndevices = ndevices;
+ return 0;
+
+cleanup:
+ virBlkioDeviceWeightArrayClear(result, ndevices);
+ VIR_FREE(result);
+ return -1;
+}
+
+static int
qemuDomainSetBlkioParameters(virDomainPtr dom,
virTypedParameterPtr params,
int nparams,
@@ -6116,6 +6160,11 @@ qemuDomainSetBlkioParameters(virDomainPtr dom,
ret = -1;
continue;
}
+ if (qemuDomainiDefineDeviceWeights(persistentDef,
+ devices,
+ ndevices) < 0)
+ ret = -1;
+
if (qemuDomainMergeDeviceWeights(&vm->def->blkio.devices,
&vm->def->blkio.ndevices,
devices, ndevices) < 0)
--
1.7.7.5
12 years, 8 months
[libvirt] [PATCH] sysinfo: simplify function signature
by Eric Blake
Now that no one is relying on the return value being a pointer to
somewhere inside of the passed-in argument, we can simplify the
callers to simply return success or failure. Also wrap some long
lines and add some const-correctness.
* src/util/sysinfo.c (virSysinfoParseBIOS, virSysinfoParseSystem)
(virSysinfoParseProcessor, virSysinfoParseMemory): Change return.
(virSysinfoRead): Adjust caller.
---
src/util/sysinfo.c | 104 ++++++++++++++++++++++++++++++---------------------
1 files changed, 61 insertions(+), 43 deletions(-)
diff --git a/src/util/sysinfo.c b/src/util/sysinfo.c
index 0e55d7e..39c7581 100644
--- a/src/util/sysinfo.c
+++ b/src/util/sysinfo.c
@@ -1,7 +1,7 @@
/*
* sysinfo.c: get SMBIOS/sysinfo information from the host
*
- * Copyright (C) 2010-2011 Red Hat, Inc.
+ * Copyright (C) 2010-2012 Red Hat, Inc.
* Copyright (C) 2010 Daniel Veillard
*
* This library is free software; you can redistribute it and/or
@@ -130,13 +130,13 @@ virSysinfoRead(void) {
#else /* !WIN32 && x86 */
-static char *
-virSysinfoParseBIOS(char *base, virSysinfoDefPtr ret)
+static int
+virSysinfoParseBIOS(const char *base, virSysinfoDefPtr ret)
{
- char *cur, *eol = NULL;
+ const char *cur, *eol = NULL;
if ((cur = strstr(base, "BIOS Information")) == NULL)
- return base;
+ return 0;
base = cur;
if ((cur = strstr(base, "Vendor: ")) != NULL) {
@@ -164,19 +164,19 @@ virSysinfoParseBIOS(char *base, virSysinfoDefPtr ret)
goto no_memory;
}
- return base + strlen("BIOS Information");
+ return 0;
no_memory:
- return NULL;
+ return -1;
}
-static char *
-virSysinfoParseSystem(char *base, virSysinfoDefPtr ret)
+static int
+virSysinfoParseSystem(const char *base, virSysinfoDefPtr ret)
{
- char *cur, *eol = NULL;
+ const char *cur, *eol = NULL;
if ((cur = strstr(base, "System Information")) == NULL)
- return base;
+ return 0;
base = cur;
if ((cur = strstr(base, "Manufacturer: ")) != NULL) {
@@ -223,16 +223,17 @@ virSysinfoParseSystem(char *base, virSysinfoDefPtr ret)
goto no_memory;
}
- return base + strlen("System Information");
+ return 0;
no_memory:
- return NULL;
+ return -1;
}
-static char *
-virSysinfoParseProcessor(char *base, virSysinfoDefPtr ret)
+static int
+virSysinfoParseProcessor(const char *base, virSysinfoDefPtr ret)
{
- char *cur, *eol, *tmp_base;
+ const char *cur, *tmp_base;
+ char *eol;
virSysinfoProcessorDefPtr processor;
while((tmp_base = strstr(base, "Processor Information")) != NULL) {
@@ -249,7 +250,8 @@ virSysinfoParseProcessor(char *base, virSysinfoDefPtr ret)
eol = strchr(cur, '\n');
virSkipSpacesBackwards(cur, &eol);
if ((eol) &&
- ((processor->processor_socket_destination = strndup(cur, eol - cur)) == NULL))
+ ((processor->processor_socket_destination
+ = strndup(cur, eol - cur)) == NULL))
goto no_memory;
}
if ((cur = strstr(base, "Type: ")) != NULL) {
@@ -265,7 +267,8 @@ virSysinfoParseProcessor(char *base, virSysinfoDefPtr ret)
eol = strchr(cur, '\n');
virSkipSpacesBackwards(cur, &eol);
if ((eol) &&
- ((processor->processor_family = strndup(cur, eol - cur)) == NULL))
+ ((processor->processor_family = strndup(cur,
+ eol - cur)) == NULL))
goto no_memory;
}
if ((cur = strstr(base, "Manufacturer: ")) != NULL) {
@@ -273,7 +276,8 @@ virSysinfoParseProcessor(char *base, virSysinfoDefPtr ret)
eol = strchr(cur, '\n');
virSkipSpacesBackwards(cur, &eol);
if ((eol) &&
- ((processor->processor_manufacturer = strndup(cur, eol - cur)) == NULL))
+ ((processor->processor_manufacturer
+ = strndup(cur, eol - cur)) == NULL))
goto no_memory;
}
if ((cur = strstr(base, "Signature: ")) != NULL) {
@@ -281,7 +285,8 @@ virSysinfoParseProcessor(char *base, virSysinfoDefPtr ret)
eol = strchr(cur, '\n');
virSkipSpacesBackwards(cur, &eol);
if ((eol) &&
- ((processor->processor_signature = strndup(cur, eol - cur)) == NULL))
+ ((processor->processor_signature
+ = strndup(cur, eol - cur)) == NULL))
goto no_memory;
}
if ((cur = strstr(base, "Version: ")) != NULL) {
@@ -289,7 +294,8 @@ virSysinfoParseProcessor(char *base, virSysinfoDefPtr ret)
eol = strchr(cur, '\n');
virSkipSpacesBackwards(cur, &eol);
if ((eol) &&
- ((processor->processor_version = strndup(cur, eol - cur)) == NULL))
+ ((processor->processor_version = strndup(cur,
+ eol - cur)) == NULL))
goto no_memory;
}
if ((cur = strstr(base, "External Clock: ")) != NULL) {
@@ -297,7 +303,8 @@ virSysinfoParseProcessor(char *base, virSysinfoDefPtr ret)
eol = strchr(cur, '\n');
virSkipSpacesBackwards(cur, &eol);
if ((eol) &&
- ((processor->processor_external_clock = strndup(cur, eol - cur)) == NULL))
+ ((processor->processor_external_clock
+ = strndup(cur, eol - cur)) == NULL))
goto no_memory;
}
if ((cur = strstr(base, "Max Speed: ")) != NULL) {
@@ -305,7 +312,8 @@ virSysinfoParseProcessor(char *base, virSysinfoDefPtr ret)
eol = strchr(cur, '\n');
virSkipSpacesBackwards(cur, &eol);
if ((eol) &&
- ((processor->processor_max_speed = strndup(cur, eol - cur)) == NULL))
+ ((processor->processor_max_speed
+ = strndup(cur, eol - cur)) == NULL))
goto no_memory;
}
if ((cur = strstr(base, "Status: ")) != NULL) {
@@ -313,7 +321,8 @@ virSysinfoParseProcessor(char *base, virSysinfoDefPtr ret)
eol = strchr(cur, '\n');
virSkipSpacesBackwards(cur, &eol);
if ((eol) &&
- ((processor->processor_status = strndup(cur, eol - cur)) == NULL))
+ ((processor->processor_status = strndup(cur,
+ eol - cur)) == NULL))
goto no_memory;
}
if ((cur = strstr(base, "Serial Number: ")) != NULL) {
@@ -321,7 +330,8 @@ virSysinfoParseProcessor(char *base, virSysinfoDefPtr ret)
eol = strchr(cur, '\n');
virSkipSpacesBackwards(cur, &eol);
if ((eol) &&
- ((processor->processor_serial_number = strndup(cur, eol - cur)) == NULL))
+ ((processor->processor_serial_number
+ = strndup(cur, eol - cur)) == NULL))
goto no_memory;
}
if ((cur = strstr(base, "Part Number: ")) != NULL) {
@@ -329,23 +339,25 @@ virSysinfoParseProcessor(char *base, virSysinfoDefPtr ret)
eol = strchr(cur, '\n');
virSkipSpacesBackwards(cur, &eol);
if ((eol) &&
- ((processor->processor_part_number = strndup(cur, eol - cur)) == NULL))
+ ((processor->processor_part_number
+ = strndup(cur, eol - cur)) == NULL))
goto no_memory;
}
base += strlen("Processor Information");
}
- return base;
+ return 0;
no_memory:
- return NULL;
+ return -1;
}
-static char *
-virSysinfoParseMemory(char *base, virSysinfoDefPtr ret)
+static int
+virSysinfoParseMemory(const char *base, virSysinfoDefPtr ret)
{
- char *cur, *eol, *tmp_base;
+ const char *cur, *tmp_base;
+ char *eol;
virSysinfoMemoryDefPtr memory;
while ((tmp_base = strstr(base, "Memory Device")) != NULL) {
@@ -373,7 +385,8 @@ virSysinfoParseMemory(char *base, virSysinfoDefPtr ret)
eol = strchr(cur, '\n');
virSkipSpacesBackwards(cur, &eol);
if ((eol) &&
- ((memory->memory_form_factor = strndup(cur, eol - cur)) == NULL))
+ ((memory->memory_form_factor = strndup(cur,
+ eol - cur)) == NULL))
goto no_memory;
}
if ((cur = strstr(base, "Locator: ")) != NULL) {
@@ -389,7 +402,8 @@ virSysinfoParseMemory(char *base, virSysinfoDefPtr ret)
eol = strchr(cur, '\n');
virSkipSpacesBackwards(cur, &eol);
if ((eol) &&
- ((memory->memory_bank_locator = strndup(cur, eol - cur)) == NULL))
+ ((memory->memory_bank_locator = strndup(cur,
+ eol - cur)) == NULL))
goto no_memory;
}
if ((cur = strstr(base, "Type: ")) != NULL) {
@@ -405,7 +419,8 @@ virSysinfoParseMemory(char *base, virSysinfoDefPtr ret)
eol = strchr(cur, '\n');
virSkipSpacesBackwards(cur, &eol);
if ((eol) &&
- ((memory->memory_type_detail = strndup(cur, eol - cur)) == NULL))
+ ((memory->memory_type_detail = strndup(cur,
+ eol - cur)) == NULL))
goto no_memory;
}
if ((cur = strstr(base, "Speed: ")) != NULL) {
@@ -421,7 +436,8 @@ virSysinfoParseMemory(char *base, virSysinfoDefPtr ret)
eol = strchr(cur, '\n');
virSkipSpacesBackwards(cur, &eol);
if ((eol) &&
- ((memory->memory_manufacturer = strndup(cur, eol - cur)) == NULL))
+ ((memory->memory_manufacturer = strndup(cur,
+ eol - cur)) == NULL))
goto no_memory;
}
if ((cur = strstr(base, "Serial Number: ")) != NULL) {
@@ -429,7 +445,8 @@ virSysinfoParseMemory(char *base, virSysinfoDefPtr ret)
eol = strchr(cur, '\n');
virSkipSpacesBackwards(cur, &eol);
if ((eol) &&
- ((memory->memory_serial_number = strndup(cur, eol - cur)) == NULL))
+ ((memory->memory_serial_number = strndup(cur,
+ eol - cur)) == NULL))
goto no_memory;
}
if ((cur = strstr(base, "Part Number: ")) != NULL) {
@@ -437,7 +454,8 @@ virSysinfoParseMemory(char *base, virSysinfoDefPtr ret)
eol = strchr(cur, '\n');
virSkipSpacesBackwards(cur, &eol);
if ((eol) &&
- ((memory->memory_part_number = strndup(cur, eol - cur)) == NULL))
+ ((memory->memory_part_number = strndup(cur,
+ eol - cur)) == NULL))
goto no_memory;
}
@@ -445,10 +463,10 @@ virSysinfoParseMemory(char *base, virSysinfoDefPtr ret)
base += strlen("Memory Device");
}
- return base;
+ return 0;
no_memory:
- return NULL;
+ return -1;
}
virSysinfoDefPtr
@@ -481,20 +499,20 @@ virSysinfoRead(void) {
ret->type = VIR_SYSINFO_SMBIOS;
- if ((virSysinfoParseBIOS(outbuf, ret)) == NULL)
+ if (virSysinfoParseBIOS(outbuf, ret) < 0)
goto no_memory;
- if ((virSysinfoParseSystem(outbuf, ret)) == NULL)
+ if (virSysinfoParseSystem(outbuf, ret) < 0)
goto no_memory;
ret->nprocessor = 0;
ret->processor = NULL;
- if ((virSysinfoParseProcessor(outbuf, ret)) == NULL)
+ if (virSysinfoParseProcessor(outbuf, ret) < 0)
goto no_memory;
ret->nmemory = 0;
ret->memory = NULL;
- if (virSysinfoParseMemory(outbuf, ret) == NULL)
+ if (virSysinfoParseMemory(outbuf, ret) < 0)
goto no_memory;
cleanup:
--
1.7.7.6
12 years, 8 months
[libvirt] The weird '@' in bind address on OSX
by Justin Clift
Hi all,
As a general thought, would anyone be interested in getting this weird '@'
thing in the bind address on OSX "fixed"?
It shows up in both libvirtd and virsh:
$ libvirtd
2012-02-08 08:39:53.211+0000: -1: info : libvirt version: 0.9.10
2012-02-08 08:39:53.211+0000: -1: error : virNetSocketNewListenUNIX:346 : Failed to bind socket to '@/Users/jc/.libvirt/libvirt-sock': No such file or directory
and
$ virsh
Welcome to virsh, the virtualization interactive terminal.
Type: 'help' for help with commands
'quit' to quit
virsh # version
error: Failed to reconnect to the hypervisor
error: no valid connection
error: Failed to connect socket to '@/Users/jc/.libvirt/libvirt-sock': No such file or directory
Matthias mentioned it's due to using anonymous unix sockets, which
are only present on Linux:
https://www.redhat.com/archives/libvirt-users/2011-November/msg00018.html
Guess that means libvirtd doesn't work on *BSD either?
Perhaps gnulib has a cross platform way to take care of this?
(Note, I could have sworn eblake started looking into this ages ago,
but then I moved on to the Aeolus team. Unsure if there was useful
progress back then. ?)
Regards and best wishes,
Justin Clift
--
Aeolus Community Manager
http://www.aeolusproject.org
12 years, 8 months
[libvirt] [PATCH] qemu: Implement DomainPMSuspendForDuration
by Michal Privoznik
via user agent.
---
src/qemu/qemu_agent.c | 31 +++++++++++++++++++
src/qemu/qemu_agent.h | 2 +
src/qemu/qemu_driver.c | 78 ++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 111 insertions(+), 0 deletions(-)
diff --git a/src/qemu/qemu_agent.c b/src/qemu/qemu_agent.c
index 9df5546..a17d025 100644
--- a/src/qemu/qemu_agent.c
+++ b/src/qemu/qemu_agent.c
@@ -1184,3 +1184,34 @@ cleanup:
virJSONValueFree(reply);
return ret;
}
+
+VIR_ENUM_DECL(qemuAgentSuspendMode);
+
+VIR_ENUM_IMPL(qemuAgentSuspendMode,
+ VIR_NODE_SUSPEND_TARGET_LAST,
+ "guest-suspend-ram",
+ "guest-suspend-disk",
+ "guest-suspend-hybrid");
+
+int
+qemuAgentSuspend(qemuAgentPtr mon,
+ unsigned int target)
+{
+ int ret = -1;
+ virJSONValuePtr cmd;
+ virJSONValuePtr reply = NULL;
+
+ cmd = qemuAgentMakeCommand(qemuAgentSuspendModeTypeToString(target),
+ NULL);
+ if (!cmd)
+ return -1;
+
+ ret = qemuAgentCommand(mon, cmd, &reply);
+
+ if (ret == 0)
+ ret = qemuAgentCheckError(cmd, reply);
+
+ virJSONValueFree(cmd);
+ virJSONValueFree(reply);
+ return ret;
+}
diff --git a/src/qemu/qemu_agent.h b/src/qemu/qemu_agent.h
index df59ef7..98c23b0 100644
--- a/src/qemu/qemu_agent.h
+++ b/src/qemu/qemu_agent.h
@@ -69,4 +69,6 @@ int qemuAgentShutdown(qemuAgentPtr mon,
int qemuAgentFSFreeze(qemuAgentPtr mon);
int qemuAgentFSThaw(qemuAgentPtr mon);
+int qemuAgentSuspend(qemuAgentPtr mon,
+ unsigned int target);
#endif /* __QEMU_AGENT_H__ */
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 52350f2..f91b885 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -12042,6 +12042,83 @@ cleanup:
return ret;
}
+static int
+qemuDomainPMSuspendForDuration(virDomainPtr dom,
+ unsigned int target,
+ unsigned long long duration,
+ unsigned int flags)
+{
+ struct qemud_driver *driver = dom->conn->privateData;
+ qemuDomainObjPrivatePtr priv;
+ virDomainObjPtr vm;
+ int ret = -1;
+
+ virCheckFlags(0, -1);
+
+ if (duration) {
+ qemuReportError(VIR_ERR_INVALID_ARG, "%s",
+ _("Duration not supported. Use 0 for now"));
+ return -1;
+ }
+
+ if (!(target == VIR_NODE_SUSPEND_TARGET_MEM ||
+ target == VIR_NODE_SUSPEND_TARGET_DISK ||
+ target == VIR_NODE_SUSPEND_TARGET_HYBRID)) {
+ qemuReportError(VIR_ERR_INVALID_ARG,
+ _("Unknown suspend target: %u"),
+ target);
+ return -1;
+ }
+
+ qemuDriverLock(driver);
+ vm = virDomainFindByUUID(&driver->domains, dom->uuid);
+ qemuDriverUnlock(driver);
+
+ if (!vm) {
+ char uuidstr[VIR_UUID_STRING_BUFLEN];
+ virUUIDFormat(dom->uuid, uuidstr);
+ qemuReportError(VIR_ERR_NO_DOMAIN,
+ _("no domain with matching uuid '%s'"), uuidstr);
+ goto cleanup;
+ }
+
+ priv = vm->privateData;
+
+ if (priv->agentError) {
+ qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("QEMU guest agent is not available due to an error"));
+ goto cleanup;
+ }
+
+ if (!priv->agent) {
+ qemuReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s",
+ _("QEMU guest agent is not configured"));
+ goto cleanup;
+ }
+
+ if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY) < 0)
+ goto cleanup;
+
+ if (!virDomainObjIsActive(vm)) {
+ qemuReportError(VIR_ERR_OPERATION_INVALID,
+ "%s", _("domain is not running"));
+ goto endjob;
+ }
+
+ qemuDomainObjEnterAgent(driver, vm);
+ ret = qemuAgentSuspend(priv->agent, target);
+ qemuDomainObjExitAgent(driver, vm);
+
+endjob:
+ if (qemuDomainObjEndJob(driver, vm) == 0)
+ vm = NULL;
+
+cleanup:
+ if (vm)
+ virDomainObjUnlock(vm);
+ return ret;
+}
+
static virDriver qemuDriver = {
.no = VIR_DRV_QEMU,
.name = "QEMU",
@@ -12199,6 +12276,7 @@ static virDriver qemuDriver = {
.domainGetDiskErrors = qemuDomainGetDiskErrors, /* 0.9.10 */
.domainSetMetadata = qemuDomainSetMetadata, /* 0.9.10 */
.domainGetMetadata = qemuDomainGetMetadata, /* 0.9.10 */
+ .domainPMSuspendForDuration = qemuDomainPMSuspendForDuration, /* 0.9.10 */
};
--
1.7.3.4
12 years, 8 months
[libvirt] [PATCH] virsh: Fix flag semantics and docs for "desc" command
by Peter Krempa
This patch fixes the domain modification impact flags for tie virsh
desc command to match the new semantics and fix the docs to match
actual behavior.
---
tools/virsh.c | 21 +++++++++++++++------
tools/virsh.pod | 12 +++++-------
2 files changed, 20 insertions(+), 13 deletions(-)
diff --git a/tools/virsh.c b/tools/virsh.c
index c107d8c..66ba61c 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -1051,7 +1051,7 @@ cmdDesc(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
virDomainPtr dom;
bool config = vshCommandOptBool(cmd, "config");
bool live = vshCommandOptBool(cmd, "live");
- /* current is ignored */
+ bool current = vshCommandOptBool(cmd, "current");
bool title = vshCommandOptBool(cmd, "title");
bool edit = vshCommandOptBool(cmd, "edit");
@@ -1068,6 +1068,19 @@ cmdDesc(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
bool ret = false;
unsigned int flags = VIR_DOMAIN_AFFECT_CURRENT;
+ if (current) {
+ if (live || config) {
+ vshError(ctl, "%s", _("--current must be specified exclusively"));
+ return false;
+ }
+ flags = VIR_DOMAIN_AFFECT_CURRENT;
+ } else {
+ if (config)
+ flags |= VIR_DOMAIN_AFFECT_CONFIG;
+ if (live)
+ flags |= VIR_DOMAIN_AFFECT_LIVE;
+ }
+
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
@@ -1084,10 +1097,6 @@ cmdDesc(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
virBufferAdd(&buf, opt->data, -1);
}
- if (live)
- flags |= VIR_DOMAIN_AFFECT_LIVE;
- if (config)
- flags |= VIR_DOMAIN_AFFECT_CONFIG;
if (title)
type = VIR_DOMAIN_METADATA_TITLE;
else
@@ -1122,7 +1131,7 @@ cmdDesc(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
/* strip a possible newline at the end of file; some
* editors enforce a newline, this makes editing the title
- * more convinient */
+ * more convenient */
if (title &&
(tmpstr = strrchr(desc_edited, '\n')) &&
*(tmpstr+1) == '\0')
diff --git a/tools/virsh.pod b/tools/virsh.pod
index a85da13..21e0f57 100644
--- a/tools/virsh.pod
+++ b/tools/virsh.pod
@@ -435,7 +435,7 @@ Define a domain from an XML <file>. The domain definition is registered
but not started. If domain is already running, the changes will take
effect on the next boot.
-=item B<desc> [I<--live> | I<--config>] [I<--title>] [I<--edit>]
+=item B<desc> [[I<--live> I<--config> | I<--current>] [I<--title>] [I<--edit>]
[I<--new-desc> New description or title message]
Show or modify description and title of a domain. These values are user
@@ -443,12 +443,10 @@ fields that allow to store arbitrary textual data to allow easy
identification of domains. Title should be short, although it's not enforced.
Flags I<--live> or I<--config> select whether this command works on live
-or persistent definitions of the domain. By default both are influenced, while
-modifying and running definition is used while reading the note.
-
-If both I<--live> and I<--config> are specified, the I<--config> option takes
-precedence on getting the current description and both live configuration
-and config are updated while setting the description.
+or persistent definitions of the domain. If both I<--live> and I<--config>
+are specified, the I<--config> option takes precedence on getting the current
+description and both live configuration and config are updated while setting
+the description. I<--current> is exclusive and implied if none of these was specified.
Flag I<--edit> specifies that an editor with the contents of current
description or title should be opened and the contents saved back afterwards.
--
1.7.6.1
12 years, 8 months
[libvirt] [PATCH v2 0/2] qemu: Fix stalls during live core dump
by Jiri Denemark
Qemu uses non-blocking I/O which doesn't play nice with regular file
descriptors. We need to pass a pipe to qemu when dumping core to avoid
stalls in live mode.
Version 2:
- generalize virFileDirectFd a bit more as suggested by Eric
Jiri Denemark (2):
util: Generalize virFileDirectFd
qemu: Always use iohelper for dumping domain core
src/qemu/qemu_driver.c | 45 +++++++++++--------
src/util/virfile.c | 118 +++++++++++++++++++++++++++++-------------------
src/util/virfile.h | 21 ++++++---
3 files changed, 112 insertions(+), 72 deletions(-)
--
1.7.8.4
12 years, 8 months