[libvirt] [PATCH] virsh: print error in case of cellno is invalid
by Osier Yang
If invalid cellno is specified, command "freecell" will still
print the amount of available memory of node. As a fix, print
error instead.
* tools/virsh.c: "vshCommandOptInt", return -1 when value for
parameter is specified, but invalid, which means strtol was
failed, it won't affects other functions that use "vshCommandOptInt").
---
tools/virsh.c | 14 ++++++++++++--
1 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/tools/virsh.c b/tools/virsh.c
index 55e2a68..31f2a54 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -2275,6 +2275,12 @@ cmdFreecell(vshControl *ctl, const vshCmd *cmd)
return FALSE;
cell = vshCommandOptInt(cmd, "cellno", &cell_given);
+
+ if (cell == -1) {
+ vshError(ctl, "%s", _("Invalid value for 'cellno', expecting an int"));
+ return FALSE;
+ }
+
if (!cell_given) {
memory = virNodeGetFreeMemory(ctl->conn);
if (memory == 0)
@@ -10440,13 +10446,17 @@ vshCommandOptInt(const vshCmd *cmd, const char *name, int *found)
if ((arg != NULL) && (arg->data != NULL)) {
res = strtol(arg->data, &end_p, 10);
- if ((arg->data == end_p) || (*end_p!= 0))
+
+ if ((arg->data == end_p) || (*end_p!= 0)) {
num_found = FALSE;
- else
+ res = -1;
+ } else
num_found = TRUE;
}
+
if (found)
*found = num_found;
+
return res;
}
--
1.7.3.2
13 years, 11 months
[libvirt] [PATCH] [v2] API: Improve log for domain related APIs
by Osier Yang
Add VM name/UUID in log for domain related APIs.
Format: "param0=%p, param1=%p, (VM: %s)"
* src/libvirt.c
---
src/libvirt.c | 293 +++++++++++++++++++++++++++++++++++++++++++--------------
1 files changed, 220 insertions(+), 73 deletions(-)
diff --git a/src/libvirt.c b/src/libvirt.c
index ee2495a..cd1cf6e 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -1961,7 +1961,9 @@ error:
virConnectPtr
virDomainGetConnect (virDomainPtr dom)
{
- DEBUG("dom=%p", dom);
+ const char *name = virDomainGetName(dom);
+
+ DEBUG("dom=%p, (VM: %s)", dom, NULLSTR(name));
virResetLastError();
@@ -2100,7 +2102,10 @@ error:
virDomainPtr
virDomainLookupByUUID(virConnectPtr conn, const unsigned char *uuid)
{
- DEBUG("conn=%p, uuid=%s", conn, uuid);
+ char uuidstr[VIR_UUID_STRING_BUFLEN];
+ virUUIDFormat(uuid, uuidstr);
+
+ DEBUG("conn=%p, uuid=%s", conn, uuidstr);
virResetLastError();
@@ -2226,8 +2231,9 @@ int
virDomainDestroy(virDomainPtr domain)
{
virConnectPtr conn;
+ const char *name = virDomainGetName(domain);
- DEBUG("domain=%p", domain);
+ DEBUG("domain=%p, (VM: %s)", domain, NULLSTR(name));
virResetLastError();
@@ -2270,7 +2276,9 @@ error:
int
virDomainFree(virDomainPtr domain)
{
- DEBUG("domain=%p", domain);
+ const char *name = virDomainGetName(domain);
+
+ DEBUG("domain=%p, (VM: %s)", domain, NULLSTR(name));
virResetLastError();
@@ -2306,13 +2314,15 @@ virDomainFree(virDomainPtr domain)
int
virDomainRef(virDomainPtr domain)
{
+ const char *name = virDomainGetName(domain);
+
if ((!VIR_IS_CONNECTED_DOMAIN(domain))) {
virLibConnError(NULL, VIR_ERR_INVALID_ARG, __FUNCTION__);
virDispatchError(NULL);
return(-1);
}
virMutexLock(&domain->conn->lock);
- DEBUG("domain=%p refs=%d", domain, domain->refs);
+ DEBUG("domain=%p refs=%d, (VM: %s)", domain, domain->refs, NULLSTR(name));
domain->refs++;
virMutexUnlock(&domain->conn->lock);
return 0;
@@ -2335,7 +2345,9 @@ int
virDomainSuspend(virDomainPtr domain)
{
virConnectPtr conn;
- DEBUG("domain=%p", domain);
+ const char *name = virDomainGetName(domain);
+
+ DEBUG("domain=%p, (VM: %s)", domain, NULLSTR(name));
virResetLastError();
@@ -2380,7 +2392,9 @@ int
virDomainResume(virDomainPtr domain)
{
virConnectPtr conn;
- DEBUG("domain=%p", domain);
+ const char *name = virDomainGetName(domain);
+
+ DEBUG("domain=%p, (VM: %s)", domain, NULLSTR(name));
virResetLastError();
@@ -2428,7 +2442,9 @@ virDomainSave(virDomainPtr domain, const char *to)
{
char filepath[4096];
virConnectPtr conn;
- DEBUG("domain=%p, to=%s", domain, to);
+ const char *name = virDomainGetName(domain);
+
+ DEBUG("domain=%p, to=%s, (VM: %s)", domain, to, NULLSTR(name));
virResetLastError();
@@ -2570,7 +2586,10 @@ virDomainCoreDump(virDomainPtr domain, const char *to, int flags)
{
char filepath[4096];
virConnectPtr conn;
- DEBUG("domain=%p, to=%s, flags=%d", domain, to, flags);
+ const char *name = virDomainGetName(domain);
+
+ DEBUG("domain=%p, to=%s, flags=%d, (VM: %s)", domain, to, flags,
+ NULLSTR(name));
virResetLastError();
@@ -2647,7 +2666,9 @@ int
virDomainShutdown(virDomainPtr domain)
{
virConnectPtr conn;
- DEBUG("domain=%p", domain);
+ const char *name = virDomainGetName(domain);
+
+ DEBUG("domain=%p, (VM: %s)", domain, NULLSTR(name));
virResetLastError();
@@ -2693,7 +2714,9 @@ int
virDomainReboot(virDomainPtr domain, unsigned int flags)
{
virConnectPtr conn;
- DEBUG("domain=%p, flags=%u", domain, flags);
+ const char *name = virDomainGetName(domain);
+
+ DEBUG("domain=%p, flags=%u, (VM: %s)", domain, flags, NULLSTR(name));
virResetLastError();
@@ -2760,7 +2783,9 @@ virDomainGetName(virDomainPtr domain)
int
virDomainGetUUID(virDomainPtr domain, unsigned char *uuid)
{
- DEBUG("domain=%p, uuid=%p", domain, uuid);
+ const char *name = virDomainGetName(domain);
+
+ DEBUG("domain=%p, uuid=%p, (VM: %s)", domain, uuid, NULLSTR(name));
virResetLastError();
@@ -2794,7 +2819,9 @@ int
virDomainGetUUIDString(virDomainPtr domain, char *buf)
{
unsigned char uuid[VIR_UUID_BUFLEN];
- DEBUG("domain=%p, buf=%p", domain, buf);
+ const char *name = virDomainGetName(domain);
+
+ DEBUG("domain=%p, buf=%p, (VM: %s)", domain, buf, NULLSTR(name));
virResetLastError();
@@ -2830,7 +2857,9 @@ error:
unsigned int
virDomainGetID(virDomainPtr domain)
{
- DEBUG("domain=%p", domain);
+ const char *name = virDomainGetName(domain);
+
+ DEBUG("domain=%p, (VM: %s)", domain, NULLSTR(name));
virResetLastError();
@@ -2855,7 +2884,9 @@ char *
virDomainGetOSType(virDomainPtr domain)
{
virConnectPtr conn;
- DEBUG("domain=%p", domain);
+ const char *name = virDomainGetName(domain);
+
+ DEBUG("domain=%p, (VM: %s)", domain, NULLSTR(name));
virResetLastError();
@@ -2896,7 +2927,9 @@ unsigned long
virDomainGetMaxMemory(virDomainPtr domain)
{
virConnectPtr conn;
- DEBUG("domain=%p", domain);
+ const char *name = virDomainGetName(domain);
+
+ DEBUG("domain=%p, (VM: %s)", domain, NULLSTR(name));
virResetLastError();
@@ -2942,7 +2975,9 @@ int
virDomainSetMaxMemory(virDomainPtr domain, unsigned long memory)
{
virConnectPtr conn;
- DEBUG("domain=%p, memory=%lu", domain, memory);
+ const char *name = virDomainGetName(domain);
+
+ DEBUG("domain=%p, memory=%lu, (VM: %s)", domain, memory, NULLSTR(name));
virResetLastError();
@@ -2995,7 +3030,9 @@ int
virDomainSetMemory(virDomainPtr domain, unsigned long memory)
{
virConnectPtr conn;
- DEBUG("domain=%p, memory=%lu", domain, memory);
+ const char *name = virDomainGetName(domain);
+
+ DEBUG("domain=%p, memory=%lu, (VM: %s)", domain, memory, NULLSTR(name));
virResetLastError();
@@ -3049,7 +3086,10 @@ virDomainSetMemoryParameters(virDomainPtr domain,
int nparams, unsigned int flags)
{
virConnectPtr conn;
- DEBUG("domain=%p, params=%p, nparams=%d, flags=%u", domain, params, nparams, flags);
+ const char *name = virDomainGetName(domain);
+
+ DEBUG("domain=%p, params=%p, nparams=%d, flags=%u, (VM: %s)",
+ domain, params, nparams, flags, NULLSTR(name));
virResetLastError();
@@ -3123,7 +3163,10 @@ virDomainGetMemoryParameters(virDomainPtr domain,
int *nparams, unsigned int flags)
{
virConnectPtr conn;
- DEBUG("domain=%p, params=%p, nparams=%d, flags=%u", domain, params, (nparams)?*nparams:-1, flags);
+ const char *name = virDomainGetName(domain);
+
+ DEBUG("domain=%p, params=%p, nparams=%d, flags=%u, (VM: %s)",
+ domain, params, (nparams)?*nparams:-1, flags, NULLSTR(name));
virResetLastError();
@@ -3167,7 +3210,9 @@ int
virDomainGetInfo(virDomainPtr domain, virDomainInfoPtr info)
{
virConnectPtr conn;
- DEBUG("domain=%p, info=%p", domain, info);
+ const char *name = virDomainGetName(domain);
+
+ DEBUG("domain=%p, info=%p, (VM: %s)", domain, info, NULLSTR(name));
virResetLastError();
@@ -3215,7 +3260,9 @@ char *
virDomainGetXMLDesc(virDomainPtr domain, int flags)
{
virConnectPtr conn;
- DEBUG("domain=%p, flags=%d", domain, flags);
+ const char *name = virDomainGetName(domain);
+
+ DEBUG("domain=%p, flags=%d, (VM: %s)", domain, flags, NULLSTR(name));
virResetLastError();
@@ -3662,8 +3709,10 @@ virDomainMigrate (virDomainPtr domain,
unsigned long bandwidth)
{
virDomainPtr ddomain = NULL;
- DEBUG("domain=%p, dconn=%p, flags=%lu, dname=%s, uri=%s, bandwidth=%lu",
- domain, dconn, flags, NULLSTR(dname), NULLSTR(uri), bandwidth);
+ const char *name = virDomainGetName(domain);
+
+ DEBUG("domain=%p, dconn=%p, flags=%lu, dname=%s, uri=%s, bandwidth=%lu, (VM: %s)",
+ domain, dconn, flags, NULLSTR(dname), NULLSTR(uri), bandwidth, NULLSTR(name));
virResetLastError();
@@ -3811,8 +3860,10 @@ virDomainMigrateToURI (virDomainPtr domain,
const char *dname,
unsigned long bandwidth)
{
- DEBUG("domain=%p, duri=%p, flags=%lu, dname=%s, bandwidth=%lu",
- domain, NULLSTR(duri), flags, NULLSTR(dname), bandwidth);
+ const char *name = virDomainGetName(domain);
+
+ DEBUG("domain=%p, duri=%p, flags=%lu, dname=%s, bandwidth=%lu, (VM: %s)",
+ domain, NULLSTR(duri), flags, NULLSTR(dname), bandwidth, NULLSTR(name));
virResetLastError();
@@ -3924,9 +3975,11 @@ virDomainMigratePerform (virDomainPtr domain,
unsigned long bandwidth)
{
virConnectPtr conn;
+ const char *name = virDomainGetName(domain);
+
VIR_DEBUG("domain=%p, cookie=%p, cookielen=%d, uri=%s, flags=%lu, "
- "dname=%s, bandwidth=%lu", domain, cookie, cookielen, uri, flags,
- NULLSTR(dname), bandwidth);
+ "dname=%s, bandwidth=%lu, (VM: %s)", domain, cookie,
+ cookielen, uri, flags, NULLSTR(dname), bandwidth, NULLSTR(name));
virResetLastError();
@@ -4290,7 +4343,9 @@ virDomainGetSchedulerType(virDomainPtr domain, int *nparams)
{
virConnectPtr conn;
char *schedtype;
- DEBUG("domain=%p, nparams=%p", domain, nparams);
+ const char *name = virDomainGetName(domain);
+
+ DEBUG("domain=%p, nparams=%p, (VM: %s)", domain, nparams, NULLSTR(name));
virResetLastError();
@@ -4335,7 +4390,10 @@ virDomainGetSchedulerParameters(virDomainPtr domain,
virSchedParameterPtr params, int *nparams)
{
virConnectPtr conn;
- DEBUG("domain=%p, params=%p, nparams=%p", domain, params, nparams);
+ const char *name = virDomainGetName(domain);
+
+ DEBUG("domain=%p, params=%p, nparams=%p, (VM: %s)", domain,
+ params, nparams, NULLSTR(name));
virResetLastError();
@@ -4378,7 +4436,10 @@ virDomainSetSchedulerParameters(virDomainPtr domain,
virSchedParameterPtr params, int nparams)
{
virConnectPtr conn;
- DEBUG("domain=%p, params=%p, nparams=%d", domain, params, nparams);
+ const char *name = virDomainGetName(domain);
+
+ DEBUG("domain=%p, params=%p, nparams=%d, (VM: %s)", domain,
+ params, nparams, NULLSTR(name));
virResetLastError();
@@ -4438,7 +4499,10 @@ virDomainBlockStats (virDomainPtr dom, const char *path,
{
virConnectPtr conn;
struct _virDomainBlockStats stats2 = { -1, -1, -1, -1, -1 };
- DEBUG("domain=%p, path=%s, stats=%p, size=%zi", dom, path, stats, size);
+ const char *name = virDomainGetName(dom);
+
+ DEBUG("domain=%p, path=%s, stats=%p, size=%zi, (VM: %s)", dom,
+ path, stats, size, NULLSTR(name));
virResetLastError();
@@ -4496,7 +4560,10 @@ virDomainInterfaceStats (virDomainPtr dom, const char *path,
virConnectPtr conn;
struct _virDomainInterfaceStats stats2 = { -1, -1, -1, -1,
-1, -1, -1, -1 };
- DEBUG("domain=%p, path=%s, stats=%p, size=%zi", dom, path, stats, size);
+ const char *name = virDomainGetName(dom);
+
+ DEBUG("domain=%p, path=%s, stats=%p, size=%zi, (VM: %s)", dom,
+ path, stats, size, NULLSTR(name));
virResetLastError();
@@ -4561,7 +4628,10 @@ int virDomainMemoryStats (virDomainPtr dom, virDomainMemoryStatPtr stats,
{
virConnectPtr conn;
unsigned long nr_stats_ret = 0;
- DEBUG("domain=%p, stats=%p, nr_stats=%u", dom, stats, nr_stats);
+ const char *name = virDomainGetName(dom);
+
+ DEBUG("domain=%p, stats=%p, nr_stats=%u, (VM: %s)", dom, stats, nr_stats,
+ NULLSTR(name));
if (flags != 0) {
virLibDomainError (dom, VIR_ERR_INVALID_ARG,
@@ -4645,8 +4715,10 @@ virDomainBlockPeek (virDomainPtr dom,
unsigned int flags)
{
virConnectPtr conn;
- DEBUG("domain=%p, path=%s, offset=%lld, size=%zi, buffer=%p",
- dom, path, offset, size, buffer);
+ const char *name = virDomainGetName(dom);
+
+ DEBUG("domain=%p, path=%s, offset=%lld, size=%zi, buffer=%p, (VM: %s)",
+ dom, path, offset, size, buffer, NULLSTR(name));
virResetLastError();
@@ -4736,8 +4808,10 @@ virDomainMemoryPeek (virDomainPtr dom,
unsigned int flags)
{
virConnectPtr conn;
- DEBUG ("domain=%p, start=%lld, size=%zi, buffer=%p, flags=%d",
- dom, start, size, buffer, flags);
+ const char *name = virDomainGetName(dom);
+
+ DEBUG ("domain=%p, start=%lld, size=%zi, buffer=%p, flags=%d, (VM: %s)",
+ dom, start, size, buffer, flags, NULLSTR(name));
virResetLastError();
@@ -4821,7 +4895,9 @@ int
virDomainGetBlockInfo(virDomainPtr domain, const char *path, virDomainBlockInfoPtr info, unsigned int flags)
{
virConnectPtr conn;
- DEBUG("domain=%p, info=%p flags=%u", domain, info, flags);
+ const char *name = virDomainGetName(domain);
+
+ DEBUG("domain=%p, info=%p flags=%u, (VM: %s)", domain, info, flags, NULLSTR(name));
virResetLastError();
@@ -4919,7 +4995,9 @@ error:
int
virDomainUndefine(virDomainPtr domain) {
virConnectPtr conn;
- DEBUG("domain=%p", domain);
+ const char *name = virDomainGetName(domain);
+
+ DEBUG("domain=%p name=%s", domain, NULLSTR(name));
virResetLastError();
@@ -5041,7 +5119,9 @@ error:
int
virDomainCreate(virDomainPtr domain) {
virConnectPtr conn;
- DEBUG("domain=%p", domain);
+ const char *name = virDomainGetName(domain);
+
+ DEBUG("domain=%p, (VM :%s)", domain, NULLSTR(name));
virResetLastError();
@@ -5084,7 +5164,9 @@ error:
int
virDomainCreateWithFlags(virDomainPtr domain, unsigned int flags) {
virConnectPtr conn;
- DEBUG("domain=%p, flags=%d", domain, flags);
+ const char *name = virDomainGetName(domain);
+
+ DEBUG("domain=%p, flags=%d, (VM: %s)", domain, flags, NULLSTR(name));
virResetLastError();
@@ -5130,7 +5212,9 @@ virDomainGetAutostart(virDomainPtr domain,
int *autostart)
{
virConnectPtr conn;
- DEBUG("domain=%p, autostart=%p", domain, autostart);
+ const char *name = virDomainGetName(domain);
+
+ DEBUG("domain=%p, autostart=%p, (VM: %s)", domain, autostart, NULLSTR(name));
virResetLastError();
@@ -5176,7 +5260,9 @@ virDomainSetAutostart(virDomainPtr domain,
int autostart)
{
virConnectPtr conn;
- DEBUG("domain=%p, autostart=%d", domain, autostart);
+ const char *name = virDomainGetName(domain);
+
+ DEBUG("domain=%p, autostart=%d, (VM: %s)", domain, autostart, NULLSTR(name));
virResetLastError();
@@ -5230,7 +5316,9 @@ int
virDomainSetVcpus(virDomainPtr domain, unsigned int nvcpus)
{
virConnectPtr conn;
- DEBUG("domain=%p, nvcpus=%u", domain, nvcpus);
+ const char *name = virDomainGetName(domain);
+
+ DEBUG("domain=%p, nvcpus=%u, (VM: %s)", domain, nvcpus, NULLSTR(name));
virResetLastError();
@@ -5296,7 +5384,10 @@ virDomainSetVcpusFlags(virDomainPtr domain, unsigned int nvcpus,
unsigned int flags)
{
virConnectPtr conn;
- DEBUG("domain=%p, nvcpus=%u, flags=%u", domain, nvcpus, flags);
+ const char *name = virDomainGetName(domain);
+
+ DEBUG("domain=%p, nvcpus=%u, flags=%u, (VM: %s)", domain,
+ nvcpus, flags, NULLSTR(name));
virResetLastError();
@@ -5359,7 +5450,9 @@ int
virDomainGetVcpusFlags(virDomainPtr domain, unsigned int flags)
{
virConnectPtr conn;
- DEBUG("domain=%p, flags=%u", domain, flags);
+ const char *name = virDomainGetName(domain);
+
+ DEBUG("domain=%p, flags=%u, (VM: %s)", domain, flags, NULLSTR(name));
virResetLastError();
@@ -5417,7 +5510,10 @@ virDomainPinVcpu(virDomainPtr domain, unsigned int vcpu,
unsigned char *cpumap, int maplen)
{
virConnectPtr conn;
- DEBUG("domain=%p, vcpu=%u, cpumap=%p, maplen=%d", domain, vcpu, cpumap, maplen);
+ const char *name = virDomainGetName(domain);
+
+ DEBUG("domain=%p, vcpu=%u, cpumap=%p, maplen=%d, (VM: %s)",
+ domain, vcpu, cpumap, maplen, NULLSTR(name));
virResetLastError();
@@ -5480,7 +5576,10 @@ virDomainGetVcpus(virDomainPtr domain, virVcpuInfoPtr info, int maxinfo,
unsigned char *cpumaps, int maplen)
{
virConnectPtr conn;
- DEBUG("domain=%p, info=%p, maxinfo=%d, cpumaps=%p, maplen=%d", domain, info, maxinfo, cpumaps, maplen);
+ const char *name = virDomainGetName(domain);
+
+ DEBUG("domain=%p, info=%p, maxinfo=%d, cpumaps=%p, maplen=%d, (VM: %s)",
+ domain, info, maxinfo, cpumaps, maplen, NULLSTR(name));
virResetLastError();
@@ -5536,7 +5635,9 @@ int
virDomainGetMaxVcpus(virDomainPtr domain)
{
virConnectPtr conn;
- DEBUG("domain=%p", domain);
+ const char *name = virDomainGetName(domain);
+
+ DEBUG("domain=%p, (VM: %s)", domain, NULLSTR(name));
virResetLastError();
@@ -5665,7 +5766,9 @@ int
virDomainAttachDevice(virDomainPtr domain, const char *xml)
{
virConnectPtr conn;
- DEBUG("domain=%p, xml=%s", domain, xml);
+ const char *name = virDomainGetName(domain);
+
+ DEBUG("domain=%p, xml=%s, (VM: %s)", domain, xml, NULLSTR(name));
virResetLastError();
@@ -5724,7 +5827,10 @@ virDomainAttachDeviceFlags(virDomainPtr domain,
const char *xml, unsigned int flags)
{
virConnectPtr conn;
- DEBUG("domain=%p, xml=%s, flags=%d", domain, xml, flags);
+ const char *name = virDomainGetName(domain);
+
+ DEBUG("domain=%p, xml=%s, flags=%d, (VM: %s)", domain, xml,
+ flags, NULLSTR(name));
virResetLastError();
@@ -5767,7 +5873,9 @@ int
virDomainDetachDevice(virDomainPtr domain, const char *xml)
{
virConnectPtr conn;
- DEBUG("domain=%p, xml=%s", domain, xml);
+ const char *name = virDomainGetName(domain);
+
+ DEBUG("domain=%p, xml=%s, (VM: %s)", domain, xml, NULLSTR(name));
virResetLastError();
@@ -5822,7 +5930,10 @@ virDomainDetachDeviceFlags(virDomainPtr domain,
const char *xml, unsigned int flags)
{
virConnectPtr conn;
- DEBUG("domain=%p, xml=%s, flags=%d", domain, xml, flags);
+ const char *name = virDomainGetName(domain);
+
+ DEBUG("domain=%p, xml=%s, flags=%d, (VM: %s)", domain, xml, flags,
+ NULLSTR(name));
virResetLastError();
@@ -5880,7 +5991,10 @@ virDomainUpdateDeviceFlags(virDomainPtr domain,
const char *xml, unsigned int flags)
{
virConnectPtr conn;
- DEBUG("domain=%p, xml=%s, flags=%d", domain, xml, flags);
+ const char *name = virDomainGetName(domain);
+
+ DEBUG("domain=%p, xml=%s, flags=%d, (VM: %s)", domain, xml, flags,
+ NULLSTR(name));
virResetLastError();
@@ -6206,7 +6320,10 @@ error:
virNetworkPtr
virNetworkLookupByUUID(virConnectPtr conn, const unsigned char *uuid)
{
- DEBUG("conn=%p, uuid=%s", conn, uuid);
+ char uuidstr[VIR_UUID_STRING_BUFLEN];
+ virUUIDFormat(uuid, uuidstr);
+
+ DEBUG("conn=%p, uuid=%s", conn, uuidstr);
virResetLastError();
@@ -11431,7 +11548,9 @@ error:
*/
int virDomainIsPersistent(virDomainPtr dom)
{
- DEBUG("dom=%p", dom);
+ const char *name = virDomainGetName(dom);
+
+ DEBUG("domain=%p, (VM: %s)", dom, NULLSTR(name));
virResetLastError();
@@ -11464,7 +11583,9 @@ error:
*/
int virDomainIsUpdated(virDomainPtr dom)
{
- DEBUG("dom=%p", dom);
+ const char *name = virDomainGetName(dom);
+
+ DEBUG("domain=%p, (VM: %s)", dom, NULLSTR(name));
virResetLastError();
@@ -12353,7 +12474,9 @@ int
virDomainGetJobInfo(virDomainPtr domain, virDomainJobInfoPtr info)
{
virConnectPtr conn;
- DEBUG("domain=%p, info=%p", domain, info);
+ const char *name = virDomainGetName(domain);
+
+ DEBUG("domain=%p, info=%p, (VM: %s)", domain, info, NULLSTR(name));
virResetLastError();
@@ -12401,8 +12524,9 @@ int
virDomainAbortJob(virDomainPtr domain)
{
virConnectPtr conn;
+ const char *name = virDomainGetName(domain);
- DEBUG("domain=%p", domain);
+ DEBUG("domain=%p, (VM: %s)", domain, NULLSTR(name));
virResetLastError();
@@ -12452,8 +12576,10 @@ virDomainMigrateSetMaxDowntime(virDomainPtr domain,
unsigned int flags)
{
virConnectPtr conn;
+ const char *name = virDomainGetName(domain);
- DEBUG("domain=%p, downtime=%llu, flags=%u", domain, downtime, flags);
+ DEBUG("domain=%p, downtime=%llu, flags=%u, (VM: %s)", domain,
+ downtime, flags, NULLSTR(name));
virResetLastError();
@@ -12522,7 +12648,10 @@ virConnectDomainEventRegisterAny(virConnectPtr conn,
void *opaque,
virFreeCallback freecb)
{
- DEBUG("conn=%p dom=%p, eventID=%d, cb=%p, opaque=%p, freecb=%p", conn, dom, eventID, cb, opaque, freecb);
+ const char *name = virDomainGetName(dom);
+
+ DEBUG("conn=%p dom=%p, eventID=%d, cb=%p, opaque=%p, freecb=%p, (VM: %s)",
+ conn, dom, eventID, cb, opaque, freecb, NULLSTR(name));
virResetLastError();
if (!VIR_IS_CONNECT(conn)) {
@@ -12614,8 +12743,9 @@ error:
int virDomainManagedSave(virDomainPtr dom, unsigned int flags)
{
virConnectPtr conn;
+ const char *name = virDomainGetName(dom);
- VIR_DEBUG("dom=%p, flags=%u", dom, flags);
+ VIR_DEBUG("dom%p, flags=%u, (VM: %s)", dom, flags, NULLSTR(name));
virResetLastError();
@@ -12662,8 +12792,9 @@ error:
int virDomainHasManagedSaveImage(virDomainPtr dom, unsigned int flags)
{
virConnectPtr conn;
+ const char *name = virDomainGetName(dom);
- VIR_DEBUG("dom=%p, flags=%u", dom, flags);
+ VIR_DEBUG("dom=%p, flags=%u, (VM: %s)", dom, flags, NULLSTR(name));
virResetLastError();
@@ -12703,8 +12834,9 @@ error:
int virDomainManagedSaveRemove(virDomainPtr dom, unsigned int flags)
{
virConnectPtr conn;
+ const char *name = virDomainGetName(dom);
- VIR_DEBUG("dom=%p, flags=%u", dom, flags);
+ VIR_DEBUG("dom=%p, flags=%u, (VM: %s)", dom, flags, NULLSTR(name));
virResetLastError();
@@ -12753,8 +12885,10 @@ virDomainSnapshotCreateXML(virDomainPtr domain,
unsigned int flags)
{
virConnectPtr conn;
+ const char *name = virDomainGetName(domain);
- DEBUG("domain=%p, xmlDesc=%s, flags=%u", domain, xmlDesc, flags);
+ DEBUG("domain=%p, xmlDesc=%s, flags=%u, (VM: %s)", domain, xmlDesc,
+ flags, NULLSTR(name));
virResetLastError();
@@ -12845,7 +12979,9 @@ int
virDomainSnapshotNum(virDomainPtr domain, unsigned int flags)
{
virConnectPtr conn;
- DEBUG("domain=%p", domain);
+ const char *name = virDomainGetName(domain);
+
+ DEBUG("domain=%p, (VM: %s)", domain, NULLSTR(name));
virResetLastError();
@@ -12887,9 +13023,10 @@ virDomainSnapshotListNames(virDomainPtr domain, char **names, int nameslen,
unsigned int flags)
{
virConnectPtr conn;
+ const char *name = virDomainGetName(domain);
- DEBUG("domain=%p, names=%p, nameslen=%d, flags=%u",
- domain, names, nameslen, flags);
+ DEBUG("domain=%p, names=%p, nameslen=%d, flags=%u, (VM: %s)",
+ domain, names, nameslen, flags, NULLSTR(name));
virResetLastError();
@@ -12938,7 +13075,10 @@ virDomainSnapshotLookupByName(virDomainPtr domain,
unsigned int flags)
{
virConnectPtr conn;
- DEBUG("domain=%p, name=%s, flags=%u", domain, name, flags);
+ const char *domname = virDomainGetName(domain);
+
+ DEBUG("domain=%p, name=%s, flags=%u, (VM: %s)", domain, domname,
+ flags, NULLSTR(name));
virResetLastError();
@@ -12982,7 +13122,9 @@ int
virDomainHasCurrentSnapshot(virDomainPtr domain, unsigned int flags)
{
virConnectPtr conn;
- DEBUG("domain=%p, flags=%u", domain, flags);
+ const char *name = virDomainGetName(domain);
+
+ DEBUG("domain=%p, flags=%u, (VM: %s)", domain, flags, NULLSTR(name));
virResetLastError();
@@ -13023,7 +13165,9 @@ virDomainSnapshotCurrent(virDomainPtr domain,
unsigned int flags)
{
virConnectPtr conn;
- DEBUG("domain=%p, flags=%u", domain, flags);
+ const char *name = virDomainGetName(domain);
+
+ DEBUG("domain=%p, flags=%u, (VM: %s)", domain, flags, NULLSTR(name));
virResetLastError();
@@ -13187,7 +13331,10 @@ int virDomainOpenConsole(virDomainPtr dom,
unsigned int flags)
{
virConnectPtr conn;
- DEBUG("dom=%p devname=%s, st=%p flags=%u", dom, NULLSTR(devname), st, flags);
+ const char *name = virDomainGetName(dom);
+
+ DEBUG("dom=%p, devname=%s, st=%p, flags=%u, (VM: %s)", dom,
+ NULLSTR(devname), st, flags, NULLSTR(name));
virResetLastError();
--
1.7.3.2
13 years, 11 months
[libvirt] [PATCH] Log an error on attempts to add a NAT rule for non-IPv4 addresses
by Laine Stump
Although the upper-layer code protected against it, it was possible to
call iptablesForwardMasquerade() with an IPv6 address and have it
attempt to add a rule to the MASQUERADE chain of ip6tables (which
doesn't exist).
This patch changes that function to check the protocol of the given
address, generate an error log if it's not IPv4 (AF_INET), and finally
hardcodes all the family parameters sent down to lower-level functions.
---
src/util/iptables.c | 17 +++++++++++++----
1 files changed, 13 insertions(+), 4 deletions(-)
diff --git a/src/util/iptables.c b/src/util/iptables.c
index 6770fe0..59f5cc7 100644
--- a/src/util/iptables.c
+++ b/src/util/iptables.c
@@ -761,10 +761,19 @@ iptablesForwardMasquerade(iptablesContext *ctx,
if (!(networkstr = iptablesFormatNetwork(netaddr, prefix)))
return -1;
+ if (!VIR_SOCKET_IS_FAMILY(netaddr, AF_INET)) {
+ /* Higher level code *should* guaranteee it's impossible to get here. */
+ iptablesError(VIR_ERR_INTERNAL_ERROR,
+ _("Attempted to NAT '%s'. NAT is only supported for IPv4."),
+ networkstr);
+ VIR_FREE(networkstr);
+ return -1;
+ }
+
if (protocol && protocol[0]) {
if (physdev && physdev[0]) {
ret = iptablesAddRemoveRule(ctx->nat_postrouting,
- VIR_SOCKET_FAMILY(netaddr),
+ AF_INET,
action,
"--source", networkstr,
"-p", protocol,
@@ -775,7 +784,7 @@ iptablesForwardMasquerade(iptablesContext *ctx,
NULL);
} else {
ret = iptablesAddRemoveRule(ctx->nat_postrouting,
- VIR_SOCKET_FAMILY(netaddr),
+ AF_INET,
action,
"--source", networkstr,
"-p", protocol,
@@ -787,7 +796,7 @@ iptablesForwardMasquerade(iptablesContext *ctx,
} else {
if (physdev && physdev[0]) {
ret = iptablesAddRemoveRule(ctx->nat_postrouting,
- VIR_SOCKET_FAMILY(netaddr),
+ AF_INET,
action,
"--source", networkstr,
"!", "--destination", networkstr,
@@ -796,7 +805,7 @@ iptablesForwardMasquerade(iptablesContext *ctx,
NULL);
} else {
ret = iptablesAddRemoveRule(ctx->nat_postrouting,
- VIR_SOCKET_FAMILY(netaddr),
+ AF_INET,
action,
"--source", networkstr,
"!", "--destination", networkstr,
--
1.7.3.4
13 years, 11 months
[libvirt] [PATCH] Improve error reporting when parsing dhcp info for virtual networks
by Laine Stump
This is partially in response to
https://bugzilla.redhat.com/show_bug.cgi?id=653300
The crash in that report was coincidentally fixed when we switched
from using inet_pton() to using virSocketParseAddr(), but the absence
of an ip address in a dhcp static host definition was still silently
ignored (and that entry discarded from the saved XML). This patch
turns that into a logged failure; likewise if the entry has neither a
mac address nor a name attribute (the entry is useless without at
least one of those, plus an ip address).
Since the network name is now pulled into this function in order for
those error logs to be more informative, the other error messages in
the function have also been changed to take advantage.
---
src/conf/network_conf.c | 32 +++++++++++++++++++-------------
1 files changed, 19 insertions(+), 13 deletions(-)
diff --git a/src/conf/network_conf.c b/src/conf/network_conf.c
index 420b94a..fe91617 100644
--- a/src/conf/network_conf.c
+++ b/src/conf/network_conf.c
@@ -295,7 +295,8 @@ int virNetworkIpDefNetmask(const virNetworkIpDefPtr def,
static int
-virNetworkDHCPRangeDefParseXML(virNetworkIpDefPtr def,
+virNetworkDHCPRangeDefParseXML(const char *networkName,
+ virNetworkIpDefPtr def,
xmlNodePtr node)
{
@@ -333,8 +334,8 @@ virNetworkDHCPRangeDefParseXML(virNetworkIpDefPtr def,
range = virSocketGetRange(&saddr, &eaddr);
if (range < 0) {
virNetworkReportError(VIR_ERR_XML_ERROR,
- _("dhcp range '%s' to '%s' invalid"),
- start, end);
+ _("Invalid dhcp range '%s' to '%s' in network '%s'"),
+ start, end, networkName);
VIR_FREE(start);
VIR_FREE(end);
return -1;
@@ -359,33 +360,38 @@ virNetworkDHCPRangeDefParseXML(virNetworkIpDefPtr def,
if ((mac != NULL) &&
(virParseMacAddr(mac, &addr[0]) != 0)) {
virNetworkReportError(VIR_ERR_INTERNAL_ERROR,
- _("cannot parse MAC address '%s'"),
- mac);
+ _("Cannot parse MAC address '%s' in network '%s'"),
+ mac, networkName);
VIR_FREE(mac);
}
name = virXMLPropString(cur, "name");
if ((name != NULL) && (!c_isalpha(name[0]))) {
virNetworkReportError(VIR_ERR_INTERNAL_ERROR,
- _("cannot use name address '%s'"),
- name);
+ _("Cannot use name address '%s' in network '%s'"),
+ name, networkName);
VIR_FREE(name);
}
/*
* You need at least one MAC address or one host name
*/
if ((mac == NULL) && (name == NULL)) {
+ virNetworkReportError(VIR_ERR_XML_ERROR,
+ _("Static host definition in network '%s' must have mac or name attribute"),
+ networkName);
VIR_FREE(mac);
VIR_FREE(name);
- cur = cur->next;
- continue;
+ return -1;
}
ip = virXMLPropString(cur, "ip");
- if (virSocketParseAddr(ip, &inaddr, AF_UNSPEC) < 0) {
+ if ((ip == NULL) ||
+ (virSocketParseAddr(ip, &inaddr, AF_UNSPEC) < 0)) {
+ virNetworkReportError(VIR_ERR_XML_ERROR,
+ _("Missing IP address in static host definition for network '%s'"),
+ networkName);
VIR_FREE(ip);
VIR_FREE(mac);
VIR_FREE(name);
- cur = cur->next;
- continue;
+ return -1;
}
VIR_FREE(ip);
if (VIR_REALLOC_N(def->hosts, def->nhosts + 1) < 0) {
@@ -541,7 +547,7 @@ virNetworkIPParseXML(const char *networkName,
while (cur != NULL) {
if (cur->type == XML_ELEMENT_NODE &&
xmlStrEqual(cur->name, BAD_CAST "dhcp")) {
- result = virNetworkDHCPRangeDefParseXML(def, cur);
+ result = virNetworkDHCPRangeDefParseXML(networkName, def, cur);
if (result)
goto error;
--
1.7.3.4
13 years, 11 months
[libvirt] announce mailing list
by Zdenek Styblik
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi,
not a long time ago there was information about announce mailing list.
One or two things ... :)
1] how can one sign-up into this list? I've been greeted with reply
"mail is blocked for this user" or something like that :)
2] announce mailing list is not mentioned at
http://www.libvirt.org/contact.html#email ; I know it's been Christmas
time and yes, I'm even willing/signing up for filling bug in bugzilla,
if needed. Just write a word.
Thank you and nice Sunday to all,
Zdenek
- --
Zdenek Styblik
Net/Linux admin
OS TurnovFree.net
email: stybla(a)turnovfree.net
jabber: stybla(a)jabber.turnovfree.net
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iEYEARECAAYFAk0gMVAACgkQ8MreUbSH7ik3mgCfSd0cXuUL1agNR1/H4gSYnWCF
W9gAoMrr+YSZhZtIuTBvzV0qqLkieOw2
=Jp+b
-----END PGP SIGNATURE-----
13 years, 11 months
[libvirt] [PATCH] docs: added libvirt-announce to contact page
by Justin Clift
Also added explicit links to the subscription and
archive pages for the user and developer mailing
lists.
---
docs/contact.html.in | 77 +++++++++++++++++++++++++++++++++-----------------
1 files changed, 51 insertions(+), 26 deletions(-)
diff --git a/docs/contact.html.in b/docs/contact.html.in
index 1a9f79a..02b7c94 100644
--- a/docs/contact.html.in
+++ b/docs/contact.html.in
@@ -8,43 +8,68 @@
<h2><a name="email">Mailing lists</a></h2>
<p>
- There are two mailing-lists:
+ There are three mailing-lists:
</p>
<dl>
- <dt><a href="https://www.redhat.com/archives/libvir-list/">libvir-list(a)redhat.com</a></dt>
- <dd>This list a place for discussions about the <strong>development</strong> of libvirt. Topics for discussion include
- <ul>
- <li>New features for libvirt</li>
- <li>Bug fixing of libvirt</li>
- <li>New hypervisor drivers</li>
- <li>Development of language bindings for libvirt API</li>
- <li>Testing and documentation of libvirt</li>
- </ul>
+ <dt><a href="https://www.redhat.com/mailman/listinfo/libvir-list">libvir-list(a)redhat.com</a> (for development)</dt>
+ <dd>
+ Archives at <a href="https://www.redhat.com/archives/libvir-list">https://www.redhat.com/archives/libvir-list</a>
+ </dd>
+ <dd>
+ This mailing list is a place for discussions about the
+ <strong>development</strong> of libvirt. Topics for discussion
+ include:
+ <ul>
+ <li>New features for libvirt</li>
+ <li>Bug fixing of libvirt</li>
+ <li>New hypervisor drivers</li>
+ <li>Development of language bindings for libvirt API</li>
+ <li>Testing and documentation of libvirt</li>
+ </ul>
+ </dd>
+
+ <dt><a href="https://www.redhat.com/mailman/listinfo/libvirt-users">libvirt-users(a)redhat.com</a> (for users)</dt>
+ <dd>
+ Archives at <a href="https://www.redhat.com/archives/libvirt-users">https://www.redhat.com/archives/libvirt-users</a>
+ </dd>
+ <dd>
+ This mailing list is a place for discussions involving libvirt
+ <strong>users</strong>. Topics for discussion include:
+ <ul>
+ <li>Usage of libvirt / virsh</li>
+ <li>Administration of libvirt</li>
+ <li>Deployment of libvirt with hypervisors</li>
+ <li>Development of applications on top of / using the libvirt API(s)</li>
+ <li>Any other topics along these lines</li>
+ </ul>
</dd>
- <dt><a href="https://www.redhat.com/archives/libvirt-users/">libvirt-users(a)redhat.com</a></dt>
- <dd>This list a place for discussions involving libvirt <strong>users</strong>. Topics for discussion include
- <ul>
- <li>Usage of libvirt / virsh</li>
- <li>Administration of libvirtd</li>
- <li>Deployment of libvirt with hypervisors</li>
- <li>Development of applications on top of / using the libvirt API(s)</li>
- <li>Any other topics along these lines</li>
- </ul>
+ <dt><a href="https://www.redhat.com/mailman/listinfo/libvirt-announce">libvirt-announce(a)redhat.com</a> (for release notices)</dt>
+ <dd>
+ Archives at <a href="https://www.redhat.com/archives/libvirt-announce">https://www.redhat.com/archives/libvirt-announce</a>
</dd>
+ <dd>
+ This mailing list is for announcements of new libvirt releases.
+ </dd>
+ <dd>
+ Subscribe to just this if you want to be notified of new releases,
+ without subscribing to either of the other mailing lists.
+ </dd>
+
</dl>
<p>
- Both mailing lists require that you subscribe before posting to the list,
- otherwise your posting will be delayed for manual approval by mailman.
- You can subscribe at the linked webpages above.
+ The user and development mailing lists require you to subscribe before
+ posting to the list. Otherwise your posting will be delayed for manual
+ approval. You can subscribe at the linked webpages above.
</p>
<p>
- Patches with explanations and provided as attachments are really appreciated and should
- be directed to the development mailing list will be discussed on the mailing list.
- If possible generate the patches by using <code>git format-patch</code> in a GIT
- clone.
+ Patches with explanations and provided as attachments are really
+ appreciated, and should be directed to the development mailing list
+ for review and discussion.
+ Wherever possible, please generate the patches by using
+ <code>git format-patch</code> in a git repository clone.
</p>
<h2><a name="irc">IRC discussion</a></h2>
--
1.7.3.2
13 years, 11 months
[libvirt] [PATCH] qemu driver: use lseek64 for setting position in logfile
by Stefan Berger
While doing some testing with Qemu and creating huge logfiles I
encountered the case where the VM could not start anymore due to the
lseek() to the end of the Qemu VM's log file failing. The patch below
replaces the two occurrences of lseek() in the relevant path with
lseek64() and solves this problem. It may be a good idea to look at
other occurrences of lseek() as well whether they should be replaced.
off_t is 8 bytes long (64 bit), so it doesn't need to be replaced with
the explicit off64_t.
To reproduce this error, you could do the following:
dd if=/dev/zero of=/var/log/libvirt/qemu/<name of VM>.log bs=1024
count=$((1024*2048))
and you should get an error like this:
error: Failed to start domain <name of VM>
error: Unable to seek to -2147482651 in /var/log/libvirt/qemu/<name of
VM>.log: Success
Signed-off-by: Stefan Berger <stefanb(a)us.ibm.com>
---
src/qemu/qemu_driver.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
Index: libvirt-acl/src/qemu/qemu_driver.c
===================================================================
--- libvirt-acl.orig/src/qemu/qemu_driver.c
+++ libvirt-acl/src/qemu/qemu_driver.c
@@ -238,7 +238,7 @@ qemudLogReadFD(const char* logDir, const
VIR_FREE(logfile);
return -1;
}
- if (pos < 0 || lseek(fd, pos, SEEK_SET) < 0) {
+ if (pos < 0 || lseek64(fd, pos, SEEK_SET) < 0) {
virReportSystemError(pos < 0 ? 0 : errno,
_("Unable to seek to %lld in %s"),
(long long) pos, logfile);
@@ -2624,7 +2624,7 @@ static int qemudStartVMDaemon(virConnect
enum virVMOperationType vmop) {
int ret;
unsigned long long qemuCmdFlags;
- int pos = -1;
+ off_t pos = -1;
char ebuf[1024];
char *pidfile = NULL;
int logfile = -1;
@@ -2839,7 +2839,7 @@ static int qemudStartVMDaemon(virConnect
virCommandWriteArgLog(cmd, logfile);
- if ((pos = lseek(logfile, 0, SEEK_END)) < 0)
+ if ((pos = lseek64(logfile, 0, SEEK_END)) < 0)
VIR_WARN("Unable to seek to end of logfile: %s",
virStrerror(errno, ebuf, sizeof ebuf));
13 years, 12 months
[libvirt] [PATCH] esx: Add domain autostart support
by Matthias Bolte
---
As we're currently in feature freeze this patch is meant to be
applied after the next release.
Matthias
src/esx/esx_driver.c | 209 +++++++++++++++++++++++++++++++++++++++-
src/esx/esx_vi.c | 6 +-
src/esx/esx_vi_generator.input | 60 ++++++++++++
src/esx/esx_vi_generator.py | 5 +-
src/esx/esx_vi_types.c | 6 +
src/esx/esx_vi_types.h | 1 +
6 files changed, 282 insertions(+), 5 deletions(-)
diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c
index 55847bc..bda5409 100644
--- a/src/esx/esx_driver.c
+++ b/src/esx/esx_driver.c
@@ -3193,6 +3193,211 @@ esxDomainUndefine(virDomainPtr domain)
+static int
+esxDomainGetAutostart(virDomainPtr domain, int *autostart)
+{
+ int result = -1;
+ esxPrivate *priv = domain->conn->privateData;
+ esxVI_String *propertyNameList = NULL;
+ esxVI_ObjectContent *hostAutoStartManager = NULL;
+ esxVI_DynamicProperty *dynamicProperty = NULL;
+ esxVI_AutoStartDefaults *defaults = NULL;
+ esxVI_AutoStartPowerInfo *powerInfo = NULL;
+ esxVI_AutoStartPowerInfo *powerInfoList = NULL;
+ esxVI_ObjectContent *virtualMachine = NULL;
+
+ *autostart = 0;
+
+ if (esxVI_EnsureSession(priv->primary) < 0) {
+ return -1;
+ }
+
+ /*
+ * Lookup HostAutoStartManagerConfig from the HostAutoStartManager because
+ * for some reason this is much faster than looking up the same info from
+ * the HostSystem config.
+ */
+
+ /* Check general autostart config */
+ if (esxVI_String_AppendValueToList(&propertyNameList,
+ "config.defaults") < 0 ||
+ esxVI_LookupObjectContentByType
+ (priv->primary,
+ priv->primary->hostSystem->configManager->autoStartManager,
+ "HostAutoStartManager", propertyNameList,
+ &hostAutoStartManager) < 0) {
+ goto cleanup;
+ }
+
+ if (hostAutoStartManager == NULL) {
+ ESX_ERROR(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("Could not retrieve the HostAutoStartManager object"));
+ goto cleanup;
+ }
+
+ for (dynamicProperty = hostAutoStartManager->propSet;
+ dynamicProperty != NULL; dynamicProperty = dynamicProperty->_next) {
+ if (STREQ(dynamicProperty->name, "config.defaults")) {
+ if (esxVI_AutoStartDefaults_CastFromAnyType(dynamicProperty->val,
+ &defaults) < 0) {
+ goto cleanup;
+ }
+
+ break;
+ }
+ }
+
+ if (defaults == NULL) {
+ ESX_ERROR(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("Could not retrieve the AutoStartDefaults object"));
+ goto cleanup;
+ }
+
+ if (defaults->enabled != esxVI_Boolean_True) {
+ /* Autostart is disabled in general, exit early here */
+ result = 0;
+ goto cleanup;
+ }
+
+ /* Check specific autostart config */
+ esxVI_String_Free(&propertyNameList);
+ esxVI_ObjectContent_Free(&hostAutoStartManager);
+
+ if (esxVI_String_AppendValueToList(&propertyNameList,
+ "config.powerInfo") < 0 ||
+ esxVI_LookupObjectContentByType
+ (priv->primary,
+ priv->primary->hostSystem->configManager->autoStartManager,
+ "HostAutoStartManager", propertyNameList,
+ &hostAutoStartManager) < 0) {
+ goto cleanup;
+ }
+
+ if (hostAutoStartManager == NULL) {
+ ESX_ERROR(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("Could not retrieve the HostAutoStartManager object"));
+ goto cleanup;
+ }
+
+ for (dynamicProperty = hostAutoStartManager->propSet;
+ dynamicProperty != NULL; dynamicProperty = dynamicProperty->_next) {
+ if (STREQ(dynamicProperty->name, "config.powerInfo")) {
+ if (esxVI_AutoStartPowerInfo_CastListFromAnyType
+ (dynamicProperty->val, &powerInfoList) < 0) {
+ goto cleanup;
+ }
+
+ break;
+ }
+ }
+
+ if (powerInfoList == NULL) {
+ /* powerInfo list is empty, exit early here */
+ result = 0;
+ goto cleanup;
+ }
+
+ if (esxVI_LookupVirtualMachineByUuid(priv->primary, domain->uuid,
+ NULL, &virtualMachine,
+ esxVI_Occurrence_RequiredItem) < 0) {
+ goto cleanup;
+ }
+
+ for (powerInfo = powerInfoList; powerInfo != NULL;
+ powerInfo = powerInfo->_next) {
+ if (STREQ(powerInfo->key->value, virtualMachine->obj->value)) {
+ if (STRCASEEQ(powerInfo->startAction, "powerOn")) {
+ *autostart = 1;
+ }
+
+ break;
+ }
+ }
+
+ result = 0;
+
+ cleanup:
+ esxVI_String_Free(&propertyNameList);
+ esxVI_ObjectContent_Free(&hostAutoStartManager);
+ esxVI_AutoStartDefaults_Free(&defaults);
+ esxVI_AutoStartPowerInfo_Free(&powerInfoList);
+ esxVI_ObjectContent_Free(&virtualMachine);
+
+ return result;
+}
+
+
+
+static int
+esxDomainSetAutostart(virDomainPtr domain, int autostart)
+{
+ int result = -1;
+ esxPrivate *priv = domain->conn->privateData;
+ esxVI_ObjectContent *virtualMachine = NULL;
+ esxVI_HostAutoStartManagerConfig *spec = NULL;
+ esxVI_AutoStartPowerInfo *powerInfo = NULL;
+
+ if (esxVI_EnsureSession(priv->primary) < 0) {
+ return -1;
+ }
+
+ if (esxVI_LookupVirtualMachineByUuid(priv->primary, domain->uuid,
+ NULL, &virtualMachine,
+ esxVI_Occurrence_RequiredItem) < 0 ||
+ esxVI_HostAutoStartManagerConfig_Alloc(&spec) < 0) {
+ goto cleanup;
+ }
+
+ if (autostart) {
+ /* Enable autostart in general */
+ if (esxVI_AutoStartDefaults_Alloc(&spec->defaults) < 0) {
+ goto cleanup;
+ }
+
+ spec->defaults->enabled = esxVI_Boolean_True;
+ }
+
+ if (esxVI_AutoStartPowerInfo_Alloc(&powerInfo) < 0 ||
+ esxVI_Int_Alloc(&powerInfo->startOrder) < 0 ||
+ esxVI_Int_Alloc(&powerInfo->startDelay) < 0 ||
+ esxVI_Int_Alloc(&powerInfo->stopDelay) < 0 ||
+ esxVI_AutoStartPowerInfo_AppendToList(&spec->powerInfo,
+ powerInfo) < 0) {
+ goto cleanup;
+ }
+
+ powerInfo->key = virtualMachine->obj;
+ powerInfo->startOrder->value = -1; /* no specific start order */
+ powerInfo->startDelay->value = -1; /* use system default */
+ powerInfo->waitForHeartbeat = esxVI_AutoStartWaitHeartbeatSetting_SystemDefault;
+ powerInfo->startAction = autostart ? (char *)"powerOn" : (char *)"none";
+ powerInfo->stopDelay->value = -1; /* use system default */
+ powerInfo->stopAction = (char *)"none";
+
+ if (esxVI_ReconfigureAutostart
+ (priv->primary,
+ priv->primary->hostSystem->configManager->autoStartManager,
+ spec) < 0) {
+ goto cleanup;
+ }
+
+ result = 0;
+
+ cleanup:
+ if (powerInfo != NULL) {
+ powerInfo->key = NULL;
+ powerInfo->startAction = NULL;
+ powerInfo->stopAction = NULL;
+ }
+
+ esxVI_ObjectContent_Free(&virtualMachine);
+ esxVI_HostAutoStartManagerConfig_Free(&spec);
+
+ return result;
+}
+
+
+
/*
* The scheduler interface exposes basically the CPU ResourceAllocationInfo:
*
@@ -4396,8 +4601,8 @@ static virDriver esxDriver = {
NULL, /* domainDetachDevice */
NULL, /* domainDetachDeviceFlags */
NULL, /* domainUpdateDeviceFlags */
- NULL, /* domainGetAutostart */
- NULL, /* domainSetAutostart */
+ esxDomainGetAutostart, /* domainGetAutostart */
+ esxDomainSetAutostart, /* domainSetAutostart */
esxDomainGetSchedulerType, /* domainGetSchedulerType */
esxDomainGetSchedulerParameters, /* domainGetSchedulerParameters */
esxDomainSetSchedulerParameters, /* domainSetSchedulerParameters */
diff --git a/src/esx/esx_vi.c b/src/esx/esx_vi.c
index 76be5a4..97e33c0 100644
--- a/src/esx/esx_vi.c
+++ b/src/esx/esx_vi.c
@@ -606,7 +606,8 @@ esxVI_Context_LookupObjectsByPath(esxVI_Context *ctx,
esxVI_String_Free(&propertyNameList);
if (esxVI_String_AppendValueListToList(&propertyNameList,
- "name\0") < 0 ||
+ "name\0"
+ "configManager\0") < 0 ||
esxVI_LookupObjectContentByType(ctx, ctx->computeResource->_reference,
"HostSystem", propertyNameList,
&hostSystemList) < 0) {
@@ -680,7 +681,8 @@ esxVI_Context_LookupObjectsByHostSystemIp(esxVI_Context *ctx,
/* Lookup HostSystem */
if (esxVI_String_AppendValueListToList(&propertyNameList,
- "name\0") < 0 ||
+ "name\0"
+ "configManager\0") < 0 ||
esxVI_FindByIp(ctx, NULL, hostSystemIpAddress, esxVI_Boolean_False,
&managedObjectReference) < 0 ||
esxVI_LookupObjectContentByType(ctx, managedObjectReference,
diff --git a/src/esx/esx_vi_generator.input b/src/esx/esx_vi_generator.input
index 2d903e4..44d1d9b 100644
--- a/src/esx/esx_vi_generator.input
+++ b/src/esx/esx_vi_generator.input
@@ -51,6 +51,13 @@
# Enumerations
#
+enum AutoStartWaitHeartbeatSetting
+ yes
+ no
+ systemDefault
+end
+
+
enum ManagedEntityStatus
gray
green
@@ -140,6 +147,26 @@ object AboutInfo
end
+object AutoStartDefaults
+ Boolean enabled o
+ Int startDelay o
+ Int stopDelay o
+ Boolean waitForHeartbeat o
+ String stopAction o
+end
+
+
+object AutoStartPowerInfo
+ ManagedObjectReference key r
+ Int startOrder r
+ Int startDelay r
+ AutoStartWaitHeartbeatSetting waitForHeartbeat r
+ String startAction r
+ Int stopDelay r
+ String stopAction r
+end
+
+
object ChoiceOption extends OptionType
ElementDescription choiceInfo rl
Int defaultIndex o
@@ -234,6 +261,33 @@ object FolderFileQuery extends FileQuery
end
+object HostAutoStartManagerConfig
+ AutoStartDefaults defaults o
+ AutoStartPowerInfo powerInfo ol
+end
+
+
+object HostConfigManager
+ ManagedObjectReference cpuScheduler o
+ ManagedObjectReference datastoreSystem o
+ ManagedObjectReference memoryManager o
+ ManagedObjectReference storageSystem o
+ ManagedObjectReference networkSystem o
+ ManagedObjectReference vmotionSystem o
+ ManagedObjectReference serviceSystem o
+ ManagedObjectReference firewallSystem o
+ ManagedObjectReference advancedOption o
+ ManagedObjectReference diagnosticSystem o
+ ManagedObjectReference autoStartManager o
+ ManagedObjectReference snmpSystem o
+ ManagedObjectReference dateTimeSystem o
+ ManagedObjectReference patchManager o
+ ManagedObjectReference bootDeviceSystem o
+ ManagedObjectReference firmwareSystem o
+ ManagedObjectReference healthStatusSystem o
+end
+
+
object HostCpuIdInfo
Int level r
String vendor o
@@ -843,6 +897,12 @@ method ReconfigVM_Task returns ManagedObjectReference r
end
+method ReconfigureAutostart
+ ManagedObjectReference _this r
+ HostAutoStartManagerConfig spec r
+end
+
+
method RefreshDatastore
ManagedObjectReference _this r
end
diff --git a/src/esx/esx_vi_generator.py b/src/esx/esx_vi_generator.py
index 4a8a9dc..3d068f3 100755
--- a/src/esx/esx_vi_generator.py
+++ b/src/esx/esx_vi_generator.py
@@ -1148,11 +1148,14 @@ additional_enum_features = { "ManagedEntityStatus" : Enum.FEATURE__ANY_TYPE
"VirtualMachinePowerState" : Enum.FEATURE__ANY_TYPE }
-additional_object_features = { "DatastoreHostMount" : Object.FEATURE__DEEP_COPY | Object.FEATURE__LIST | Object.FEATURE__ANY_TYPE,
+additional_object_features = { "AutoStartDefaults" : Object.FEATURE__ANY_TYPE,
+ "AutoStartPowerInfo" : Object.FEATURE__ANY_TYPE | Object.FEATURE__LIST,
+ "DatastoreHostMount" : Object.FEATURE__DEEP_COPY | Object.FEATURE__LIST | Object.FEATURE__ANY_TYPE,
"DatastoreInfo" : Object.FEATURE__ANY_TYPE | Object.FEATURE__DYNAMIC_CAST,
"Event" : Object.FEATURE__LIST,
"FileInfo" : Object.FEATURE__DYNAMIC_CAST,
"FileQuery" : Object.FEATURE__DYNAMIC_CAST,
+ "HostConfigManager" : Object.FEATURE__ANY_TYPE,
"HostCpuIdInfo" : Object.FEATURE__ANY_TYPE | Object.FEATURE__LIST,
"HostDatastoreBrowserSearchResults" : Object.FEATURE__LIST | Object.FEATURE__ANY_TYPE,
"ManagedObjectReference" : Object.FEATURE__ANY_TYPE,
diff --git a/src/esx/esx_vi_types.c b/src/esx/esx_vi_types.c
index a70e1e0..4ee4110 100644
--- a/src/esx/esx_vi_types.c
+++ b/src/esx/esx_vi_types.c
@@ -1815,6 +1815,7 @@ ESX_VI__TEMPLATE__VALIDATE(HostSystem,
ESX_VI__TEMPLATE__PROPERTY__REQUIRE(name);
/* HostSystem */
+ ESX_VI__TEMPLATE__PROPERTY__REQUIRE(configManager);
})
int
@@ -1851,6 +1852,11 @@ esxVI_HostSystem_CastFromObjectContent(esxVI_ObjectContent *objectContent,
virReportOOMError();
goto failure;
}
+ } else if (STREQ(dynamicProperty->name, "configManager")) {
+ if (esxVI_HostConfigManager_CastFromAnyType
+ (dynamicProperty->val, &(*hostSystem)->configManager) < 0) {
+ goto failure;
+ }
}
}
diff --git a/src/esx/esx_vi_types.h b/src/esx/esx_vi_types.h
index 64bf2dc..1ab39da 100644
--- a/src/esx/esx_vi_types.h
+++ b/src/esx/esx_vi_types.h
@@ -412,6 +412,7 @@ struct _esxVI_HostSystem {
char *name; /* required */
/* HostSystem */
+ esxVI_HostConfigManager *configManager; /* required */
};
int esxVI_HostSystem_Alloc(esxVI_HostSystem **hostSystem);
--
1.7.0.4
13 years, 12 months
[libvirt] [PATCH v2] qemu driver: use lseek64 for setting position in logfile
by Stefan Berger
V2:
- removed replacements of lseek() to lseek64() from patch
While doing some testing with Qemu and creating huge logfiles I
encountered the case where the VM could not start anymore due to the
lseek() to the end of the Qemu VM's log file failing. The patch below
fixes the problem by replacing the previously used 'int' with 'off_t'.
To reproduce this error, you could do the following:
dd if=/dev/zero of=/var/log/libvirt/qemu/<name of VM>.log bs=1024
count=$((1024*2048))
and you should get an error like this:
error: Failed to start domain <name of VM>
error: Unable to seek to -2147482651 in /var/log/libvirt/qemu/<name of
VM>.log: Success
Signed-off-by: Stefan Berger <stefanb(a)us.ibm.com>
---
src/qemu/qemu_driver.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
Index: libvirt-acl/src/qemu/qemu_driver.c
===================================================================
--- libvirt-acl.orig/src/qemu/qemu_driver.c
+++ libvirt-acl/src/qemu/qemu_driver.c
@@ -2624,7 +2624,7 @@ static int qemudStartVMDaemon(virConnect
enum virVMOperationType vmop) {
int ret;
unsigned long long qemuCmdFlags;
- int pos = -1;
+ off_t pos = -1;
char ebuf[1024];
char *pidfile = NULL;
int logfile = -1;
13 years, 12 months
Re: [libvirt] virsh + ssh
by Daniel Huhardeaux
Le 04/01/2011 18:24, Eric Blake a écrit :
> On 01/04/2011 10:13 AM, Daniel Huhardeaux wrote:
>> My problem was that I wanted to do it with virt-manager which only
>> connect using URI qemu+ssh://root@remote/system :-(
>
> virt-manager lets you add a new connection and specify the username. On
> virt-manager-0.8.5-1.fc14 (fedora 14 box), I just tried File->add
> connection; hypervisor qemu/kvm, check the box for remote host, method
> ssh, and then you can specify both username and host, at which point it
> displays a generated URI of qemu+ssh://user@remote/system.
[...]
Got it: virt-manager from Debian unstable was not uptodate due to Stable
freeze. Just grab from experimental and it's like you describe it. Sorry
for noise.
--
Daniel
13 years, 12 months