[Libvir] [RFC] Add Container support to libvirt
by Dave Leskovec
Greetings,
I'd like to extend libvirt to support Containers. As libvirt already
supports Xen, KVM, QEMU and OpenVZ, I think it would be valuable to be
able to utilize existing utilities to manage containers.
I've spent some time looking through the libvirt api and how this
Container support will fit. Based on the XML format section of the
libvirt website and some list discussions I put together the following
proposed XML format:
<domain type='linuxcontainer'>
<name>Container123</name>
<uuid>8dfd44b31e76d8d335150a2d98211ea0</uuid>
<container>
<filesystem>
<mount>/etc = /home/user/lxc_files/etc</mount>
<mount>/var = /home/user/lxc_files/var</mount>
</filesystem>
<application>dbserver</application>
<network hostname='browndog'>
<ip address="192.168.1.110" netmask="255.255.255.0"/>
<gateway address="192.168.1.1"/>
<nameserver>192.168.1.1</nameserver>
</ip>
</network>
<cpushare>40</cpushare>
<memory>65536</memory>
</container>
<devices>
<console tty='/dev/pts/4' />
</devices>
</domain>
The clone() function is used with the CLONE_NEWPID and CLONE_NEWNS flags
to start a new process within it's own process name space. The only
processes visible to it will be itself and any processes that it
spawns. The process that clone creates will start out preparing the
container environment. This involves setting up any network interface,
setting up the file system by performing any requested mounts, mounting
/proc, setting up a tty device, populating /dev as necessary, and
performing any other necessary initializations. It will then start the
application(s) requested by the user. The executables started within
the container could be an application or script or possibly /sbin/init.
The mounts that the user specifies will need to be populated with the
appropriate contents for whatever applications they are going to run
within the container. cgroup will be used for isolation and association
with controllers for cpu and memory resources.
I'm planning to start in on defining a container. All comments and
questions are welcome.
Best Regards,
Dave Leskovec
IBM Linux Technology Center
Open Virtualization
16 years, 12 months
[Libvir] avoid more format string warnings
by Jim Meyering
I compiled libvirt with the latest gcc in rawhide and these CFLAGS:
-O
-Wall
-Wcast-align
-Wextra
-Wformat
-Wformat-security
-Winit-self
-Winline
-Wmissing-prototypes
-Wnested-externs
-Wno-sign-compare
-Wp,-D_FORTIFY_SOURCE=2
-Wpointer-arith
-Wredundant-decls
-Wshadow
-Wstrict-prototypes
-Wwrite-strings
and ended up with a whole bunch of these warnings:
virsh.c:6896: warning: format not a string literal and no format arguments
Here's the patch:
Avoid new format string warnings.
* src/virsh.c: Add "%s" where needed.
* src/proxy_internal.c: Likewise.
---
src/proxy_internal.c | 8 ++--
src/virsh.c | 148 +++++++++++++++++++++++++-------------------------
2 files changed, 79 insertions(+), 77 deletions(-)
diff --git a/src/proxy_internal.c b/src/proxy_internal.c
index 7f902c5..e0e5631 100644
--- a/src/proxy_internal.c
+++ b/src/proxy_internal.c
@@ -499,10 +499,10 @@ retry:
*/
if ((res == NULL) || (res->version != PROXY_PROTO_VERSION) ||
(res->len < sizeof(virProxyPacket))) {
- fprintf(stderr,
- _("Communication error with proxy: malformed packet\n"));
- xenProxyClose(conn);
- return(-1);
+ fprintf(stderr, "%s",
+ _("Communication error with proxy: malformed packet\n"));
+ xenProxyClose(conn);
+ return(-1);
}
if (res->serial != serial) {
TODO /* Asynchronous communication */
diff --git a/src/virsh.c b/src/virsh.c
index 6604eea..cbe3e8e 100644
--- a/src/virsh.c
+++ b/src/virsh.c
@@ -351,7 +351,7 @@ cmdMonitorProgress(vshControl *ctl, vshCmd *cmd, virJobPtr job, virJobInfoPtr in
do {
if (virJobGetInfo(job, info) < 0) {
- vshError(ctl, FALSE, _("Failed to get job status"));
+ vshError(ctl, FALSE, "%s", _("Failed to get job status"));
return -1;
}
@@ -437,7 +437,7 @@ cmdHelp(vshControl * ctl, vshCmd * cmd)
if (!cmdname) {
vshCmdDef *def;
- vshPrint(ctl, _("Commands:\n\n"));
+ vshPrint(ctl, "%s", _("Commands:\n\n"));
for (def = commands; def->name; def++)
vshPrint(ctl, " %-15s %s\n", def->name,
N_(vshCmddefGetInfo(def, "help")));
@@ -522,7 +522,7 @@ cmdConnect(vshControl * ctl, vshCmd * cmd)
if (ctl->conn) {
if (virConnectClose(ctl->conn) != 0) {
- vshError(ctl, FALSE,
+ vshError(ctl, FALSE, "%s",
_("Failed to disconnect from the hypervisor"));
return FALSE;
}
@@ -542,7 +542,7 @@ cmdConnect(vshControl * ctl, vshCmd * cmd)
}
if (!ctl->conn)
- vshError(ctl, FALSE, _("Failed to connect to the hypervisor"));
+ vshError(ctl, FALSE, "%s", _("Failed to connect to the hypervisor"));
return ctl->conn ? TRUE : FALSE;
}
@@ -601,7 +601,7 @@ cmdConsole(vshControl * ctl, vshCmd * cmd)
if (vshRunConsole((const char *)obj->stringval) == 0)
ret = TRUE;
} else {
- vshPrintExtra(ctl, _("No console available for domain\n"));
+ vshPrintExtra(ctl, "%s", _("No console available for domain\n"));
}
xmlXPathFreeObject(obj);
@@ -619,7 +619,7 @@ cmdConsole(vshControl * ctl, vshCmd * cmd)
static int
cmdConsole(vshControl * ctl, vshCmd * cmd ATTRIBUTE_UNUSED)
{
- vshError (ctl, FALSE, _("console not implemented on this platform"));
+ vshError (ctl, FALSE, "%s", _("console not implemented on this platform"));
return FALSE;
}
@@ -659,14 +659,14 @@ cmdList(vshControl * ctl, vshCmd * cmd ATTRIBUTE_UNUSED)
if (active) {
maxid = virConnectNumOfDomains(ctl->conn);
if (maxid < 0) {
- vshError(ctl, FALSE, _("Failed to list active domains"));
+ vshError(ctl, FALSE, "%s", _("Failed to list active domains"));
return FALSE;
}
if (maxid) {
ids = vshMalloc(ctl, sizeof(int) * maxid);
if ((maxid = virConnectListDomains(ctl->conn, &ids[0], maxid)) < 0) {
- vshError(ctl, FALSE, _("Failed to list active domains"));
+ vshError(ctl, FALSE, "%s", _("Failed to list active domains"));
free(ids);
return FALSE;
}
@@ -677,7 +677,7 @@ cmdList(vshControl * ctl, vshCmd * cmd ATTRIBUTE_UNUSED)
if (inactive) {
maxname = virConnectNumOfDefinedDomains(ctl->conn);
if (maxname < 0) {
- vshError(ctl, FALSE, _("Failed to list inactive domains"));
+ vshError(ctl, FALSE, "%s", _("Failed to list inactive domains"));
if (ids)
free(ids);
return FALSE;
@@ -686,7 +686,7 @@ cmdList(vshControl * ctl, vshCmd * cmd ATTRIBUTE_UNUSED)
names = vshMalloc(ctl, sizeof(char *) * maxname);
if ((maxname = virConnectListDefinedDomains(ctl->conn, names, maxname)) < 0) {
- vshError(ctl, FALSE, _("Failed to list inactive domains"));
+ vshError(ctl, FALSE, "%s", _("Failed to list inactive domains"));
if (ids)
free(ids);
free(names);
@@ -1004,7 +1004,7 @@ cmdCreate(vshControl * ctl, vshCmd * cmd)
virDomainGetName(dom), from);
virDomainFree(dom);
} else if (info.state == VIR_JOB_CANCELLED) {
- vshError(ctl, FALSE, _("Cancelled domain create operation"));
+ vshError(ctl, FALSE, "%s", _("Cancelled domain create operation"));
ret = FALSE;
} else {
vshError(ctl, FALSE, _("Failed to create domain from %s"), from);
@@ -1145,7 +1145,7 @@ cmdStart(vshControl * ctl, vshCmd * cmd)
return FALSE;
if (virDomainGetID(dom) != (unsigned int)-1) {
- vshError(ctl, FALSE, _("Domain is already active"));
+ vshError(ctl, FALSE, "%s", _("Domain is already active"));
virDomainFree(dom);
return FALSE;
}
@@ -1172,7 +1172,7 @@ cmdStart(vshControl * ctl, vshCmd * cmd)
vshPrint(ctl, _("Domain %s started\n"),
virDomainGetName(dom));
} else if (info.state == VIR_JOB_CANCELLED) {
- vshError(ctl, FALSE, _("Cancelled domain start operation"));
+ vshError(ctl, FALSE, "%s", _("Cancelled domain start operation"));
ret = FALSE;
} else {
vshError(ctl, FALSE, _("Failed to start domain %s"),
@@ -1248,7 +1248,7 @@ cmdSave(vshControl * ctl, vshCmd * cmd)
if (info.state == VIR_JOB_COMPLETE) {
vshPrint(ctl, _("Domain %s saved to %s\n"), name, to);
} else if (info.state == VIR_JOB_CANCELLED) {
- vshError(ctl, FALSE, _("Cancelled domain save operation"));
+ vshError(ctl, FALSE, "%s", _("Cancelled domain save operation"));
ret = FALSE;
} else {
vshError(ctl, FALSE, _("Failed to save domain %s to %s"), name, to);
@@ -1313,7 +1313,7 @@ cmdSchedinfo(vshControl * ctl, vshCmd * cmd)
if(vshCommandOptBool(cmd, "weight")) {
weight = vshCommandOptInt(cmd, "weight", &weightfound);
if (!weightfound) {
- vshError(ctl, FALSE, _("Invalid value of weight"));
+ vshError(ctl, FALSE, "%s", _("Invalid value of weight"));
goto cleanup;
} else {
nr_inputparams++;
@@ -1323,7 +1323,7 @@ cmdSchedinfo(vshControl * ctl, vshCmd * cmd)
if(vshCommandOptBool(cmd, "cap")) {
cap = vshCommandOptInt(cmd, "cap", &capfound);
if (!capfound) {
- vshError(ctl, FALSE, _("Invalid value of cap"));
+ vshError(ctl, FALSE, "%s", _("Invalid value of cap"));
goto cleanup;
} else {
nr_inputparams++;
@@ -1468,7 +1468,7 @@ cmdRestore(vshControl * ctl, vshCmd * cmd)
if (info.state == VIR_JOB_COMPLETE) {
vshPrint(ctl, _("Domain restored from %s\n"),from);
} else if (info.state == VIR_JOB_CANCELLED) {
- vshError(ctl, FALSE, _("Cancelled domain restore operation"));
+ vshError(ctl, FALSE, "%s", _("Cancelled domain restore operation"));
ret = FALSE;
} else {
vshError(ctl, FALSE, _("Failed to restore domain from %s"), from);
@@ -1541,7 +1541,7 @@ cmdDump(vshControl * ctl, vshCmd * cmd)
if (info.state == VIR_JOB_COMPLETE) {
vshPrint(ctl, _("Domain %s dumped to %s\n"), name, to);
} else if (info.state == VIR_JOB_CANCELLED) {
- vshError(ctl, FALSE, _("Cancelled domain dump operation"));
+ vshError(ctl, FALSE, "%s", _("Cancelled domain dump operation"));
ret = FALSE;
} else {
vshError(ctl, FALSE, _("Failed to core dump domain %s to %s"),
@@ -1913,7 +1913,7 @@ cmdVcpuinfo(vshControl * ctl, vshCmd * cmd)
}
} else {
if (info.state == VIR_DOMAIN_SHUTOFF) {
- vshError(ctl, FALSE,
+ vshError(ctl, FALSE, "%s",
_("Domain shut off, virtual CPUs not present."));
}
ret = FALSE;
@@ -1993,7 +1993,7 @@ cmdVcpupin(vshControl * ctl, vshCmd * cmd)
* numbers and give an intelligent error message if not.
*/
if (cpulist[0] == '\0') {
- vshError(ctl, FALSE, _("cpulist: Invalid format. Empty string."));
+ vshError(ctl, FALSE, "%s", _("cpulist: Invalid format. Empty string."));
virDomainFree (dom);
return FALSE;
}
@@ -2085,7 +2085,7 @@ cmdSetvcpus(vshControl * ctl, vshCmd * cmd)
count = vshCommandOptInt(cmd, "count", &count);
if (count <= 0) {
- vshError(ctl, FALSE, _("Invalid number of virtual CPUs."));
+ vshError(ctl, FALSE, "%s", _("Invalid number of virtual CPUs."));
virDomainFree(dom);
return FALSE;
}
@@ -2097,7 +2097,7 @@ cmdSetvcpus(vshControl * ctl, vshCmd * cmd)
}
if (count > maxcpu) {
- vshError(ctl, FALSE, _("Too many virtual CPUs."));
+ vshError(ctl, FALSE, "%s", _("Too many virtual CPUs."));
virDomainFree(dom);
return FALSE;
}
@@ -2149,7 +2149,7 @@ cmdSetmem(vshControl * ctl, vshCmd * cmd)
if (virDomainGetInfo(dom, &info) != 0) {
virDomainFree(dom);
- vshError(ctl, FALSE, _("Unable to verify MaxMemorySize"));
+ vshError(ctl, FALSE, "%s", _("Unable to verify MaxMemorySize"));
return FALSE;
}
@@ -2206,20 +2206,20 @@ cmdSetmaxmem(vshControl * ctl, vshCmd * cmd)
if (virDomainGetInfo(dom, &info) != 0) {
virDomainFree(dom);
- vshError(ctl, FALSE, _("Unable to verify current MemorySize"));
+ vshError(ctl, FALSE, "%s", _("Unable to verify current MemorySize"));
return FALSE;
}
if (kilobytes < info.memory) {
if (virDomainSetMemory(dom, kilobytes) != 0) {
virDomainFree(dom);
- vshError(ctl, FALSE, _("Unable to shrink current MemorySize"));
+ vshError(ctl, FALSE, "%s", _("Unable to shrink current MemorySize"));
return FALSE;
}
}
if (virDomainSetMaxMemory(dom, kilobytes) != 0) {
- vshError(ctl, FALSE, _("Unable to change MaxMemorySize"));
+ vshError(ctl, FALSE, "%s", _("Unable to change MaxMemorySize"));
ret = FALSE;
}
@@ -2246,7 +2246,7 @@ cmdNodeinfo(vshControl * ctl, vshCmd * cmd ATTRIBUTE_UNUSED)
return FALSE;
if (virNodeGetInfo(ctl->conn, &info) < 0) {
- vshError(ctl, FALSE, _("failed to get node information"));
+ vshError(ctl, FALSE, "%s", _("failed to get node information"));
return FALSE;
}
vshPrint(ctl, "%-20s %s\n", _("CPU model:"), info.model);
@@ -2280,7 +2280,7 @@ cmdCapabilities (vshControl * ctl, vshCmd * cmd ATTRIBUTE_UNUSED)
return FALSE;
if ((caps = virConnectGetCapabilities (ctl->conn)) == NULL) {
- vshError(ctl, FALSE, _("failed to get capabilities"));
+ vshError(ctl, FALSE, "%s", _("failed to get capabilities"));
return FALSE;
}
vshPrint (ctl, "%s\n", caps);
@@ -2422,7 +2422,7 @@ cmdDomuuid(vshControl * ctl, vshCmd * cmd)
if (virDomainGetUUIDString(dom, uuid) != -1)
vshPrint(ctl, "%s\n", uuid);
else
- vshError(ctl, FALSE, _("failed to get domain UUID"));
+ vshError(ctl, FALSE, "%s", _("failed to get domain UUID"));
return TRUE;
}
@@ -2463,7 +2463,7 @@ cmdMigrate (vshControl *ctl, vshCmd *cmd)
desturi = vshCommandOptString (cmd, "desturi", &found);
if (!found) {
- vshError (ctl, FALSE, _("migrate: Missing desturi"));
+ vshError (ctl, FALSE, "%s", _("migrate: Missing desturi"));
goto done;
}
@@ -2599,7 +2599,7 @@ cmdNetworkCreate(vshControl * ctl, vshCmd * cmd)
virNetworkGetName(dom), from);
virNetworkFree(dom);
} else if (info.state == VIR_JOB_CANCELLED) {
- vshError(ctl, FALSE, _("Cancelled network create operation"));
+ vshError(ctl, FALSE, "%s", _("Cancelled network create operation"));
ret = FALSE;
} else {
vshError(ctl, FALSE, _("Failed to create network from %s"), from);
@@ -2783,7 +2783,7 @@ cmdNetworkList(vshControl * ctl, vshCmd * cmd ATTRIBUTE_UNUSED)
if (active) {
maxactive = virConnectNumOfNetworks(ctl->conn);
if (maxactive < 0) {
- vshError(ctl, FALSE, _("Failed to list active networks"));
+ vshError(ctl, FALSE, "%s", _("Failed to list active networks"));
return FALSE;
}
if (maxactive) {
@@ -2791,7 +2791,7 @@ cmdNetworkList(vshControl * ctl, vshCmd * cmd ATTRIBUTE_UNUSED)
if ((maxactive = virConnectListNetworks(ctl->conn, activeNames,
maxactive)) < 0) {
- vshError(ctl, FALSE, _("Failed to list active networks"));
+ vshError(ctl, FALSE, "%s", _("Failed to list active networks"));
free(activeNames);
return FALSE;
}
@@ -2802,7 +2802,7 @@ cmdNetworkList(vshControl * ctl, vshCmd * cmd ATTRIBUTE_UNUSED)
if (inactive) {
maxinactive = virConnectNumOfDefinedNetworks(ctl->conn);
if (maxinactive < 0) {
- vshError(ctl, FALSE, _("Failed to list inactive networks"));
+ vshError(ctl, FALSE, "%s", _("Failed to list inactive networks"));
if (activeNames)
free(activeNames);
return FALSE;
@@ -2811,7 +2811,7 @@ cmdNetworkList(vshControl * ctl, vshCmd * cmd ATTRIBUTE_UNUSED)
inactiveNames = vshMalloc(ctl, sizeof(char *) * maxinactive);
if ((maxinactive = virConnectListDefinedNetworks(ctl->conn, inactiveNames, maxinactive)) < 0) {
- vshError(ctl, FALSE, _("Failed to list inactive networks"));
+ vshError(ctl, FALSE, "%s", _("Failed to list inactive networks"));
if (activeNames)
free(activeNames);
free(inactiveNames);
@@ -2961,7 +2961,7 @@ cmdNetworkStart(vshControl * ctl, vshCmd * cmd)
vshPrint(ctl, _("Network %s started\n"),
virNetworkGetName(network));
} else if (info.state == VIR_JOB_CANCELLED) {
- vshError(ctl, FALSE, _("Cancelled network start operation"));
+ vshError(ctl, FALSE, "%s", _("Cancelled network start operation"));
ret = FALSE;
} else {
vshError(ctl, FALSE, _("Failed to start network %s"),
@@ -3053,7 +3053,7 @@ cmdNetworkUuid(vshControl * ctl, vshCmd * cmd)
if (virNetworkGetUUIDString(network, uuid) != -1)
vshPrint(ctl, "%s\n", uuid);
else
- vshError(ctl, FALSE, _("failed to get network UUID"));
+ vshError(ctl, FALSE, "%s", _("failed to get network UUID"));
return TRUE;
}
@@ -3567,7 +3567,7 @@ cmdPoolList(vshControl * ctl, vshCmd * cmd ATTRIBUTE_UNUSED)
if (active) {
maxactive = virConnectNumOfStoragePools(ctl->conn);
if (maxactive < 0) {
- vshError(ctl, FALSE, _("Failed to list active pools"));
+ vshError(ctl, FALSE, "%s", _("Failed to list active pools"));
return FALSE;
}
if (maxactive) {
@@ -3575,7 +3575,7 @@ cmdPoolList(vshControl * ctl, vshCmd * cmd ATTRIBUTE_UNUSED)
if ((maxactive = virConnectListStoragePools(ctl->conn, activeNames,
maxactive)) < 0) {
- vshError(ctl, FALSE, _("Failed to list active pools"));
+ vshError(ctl, FALSE, "%s", _("Failed to list active pools"));
free(activeNames);
return FALSE;
}
@@ -3586,7 +3586,7 @@ cmdPoolList(vshControl * ctl, vshCmd * cmd ATTRIBUTE_UNUSED)
if (inactive) {
maxinactive = virConnectNumOfDefinedStoragePools(ctl->conn);
if (maxinactive < 0) {
- vshError(ctl, FALSE, _("Failed to list inactive pools"));
+ vshError(ctl, FALSE, "%s", _("Failed to list inactive pools"));
if (activeNames)
free(activeNames);
return FALSE;
@@ -3595,7 +3595,7 @@ cmdPoolList(vshControl * ctl, vshCmd * cmd ATTRIBUTE_UNUSED)
inactiveNames = vshMalloc(ctl, sizeof(char *) * maxinactive);
if ((maxinactive = virConnectListDefinedStoragePools(ctl->conn, inactiveNames, maxinactive)) < 0) {
- vshError(ctl, FALSE, _("Failed to list inactive pools"));
+ vshError(ctl, FALSE, "%s", _("Failed to list inactive pools"));
if (activeNames)
free(activeNames);
free(inactiveNames);
@@ -3701,7 +3701,7 @@ cmdPoolDiscover(vshControl * ctl, vshCmd * cmd ATTRIBUTE_UNUSED)
type,
0,
&xmlDesc)) < 0) {
- vshError(ctl, FALSE, _("Failed to discover pools"));
+ vshError(ctl, FALSE, "%s", _("Failed to discover pools"));
return FALSE;
}
@@ -3934,7 +3934,7 @@ cmdPoolUuid(vshControl * ctl, vshCmd * cmd)
if (virStoragePoolGetUUIDString(pool, uuid) != -1)
vshPrint(ctl, "%s\n", uuid);
else
- vshError(ctl, FALSE, _("failed to get pool UUID"));
+ vshError(ctl, FALSE, "%s", _("failed to get pool UUID"));
return TRUE;
}
@@ -4310,7 +4310,7 @@ cmdVolList(vshControl * ctl, vshCmd * cmd ATTRIBUTE_UNUSED)
maxactive = virStoragePoolNumOfVolumes(pool);
if (maxactive < 0) {
virStoragePoolFree(pool);
- vshError(ctl, FALSE, _("Failed to list active vols"));
+ vshError(ctl, FALSE, "%s", _("Failed to list active vols"));
return FALSE;
}
if (maxactive) {
@@ -4318,7 +4318,7 @@ cmdVolList(vshControl * ctl, vshCmd * cmd ATTRIBUTE_UNUSED)
if ((maxactive = virStoragePoolListVolumes(pool, activeNames,
maxactive)) < 0) {
- vshError(ctl, FALSE, _("Failed to list active vols"));
+ vshError(ctl, FALSE, "%s", _("Failed to list active vols"));
free(activeNames);
virStoragePoolFree(pool);
return FALSE;
@@ -4491,7 +4491,7 @@ cmdVersion(vshControl * ctl, vshCmd * cmd ATTRIBUTE_UNUSED)
hvType = virConnectGetType(ctl->conn);
if (hvType == NULL) {
- vshError(ctl, FALSE, _("failed to get hypervisor type"));
+ vshError(ctl, FALSE, "%s", _("failed to get hypervisor type"));
return FALSE;
}
@@ -4505,7 +4505,7 @@ cmdVersion(vshControl * ctl, vshCmd * cmd ATTRIBUTE_UNUSED)
ret = virGetVersion(&libVersion, hvType, &apiVersion);
if (ret < 0) {
- vshError(ctl, FALSE, _("failed to get the library version"));
+ vshError(ctl, FALSE, "%s", _("failed to get the library version"));
return FALSE;
}
major = libVersion / 1000000;
@@ -4524,7 +4524,7 @@ cmdVersion(vshControl * ctl, vshCmd * cmd ATTRIBUTE_UNUSED)
ret = virConnectGetVersion(ctl->conn, &hvVersion);
if (ret < 0) {
- vshError(ctl, FALSE, _("failed to get the hypervisor version"));
+ vshError(ctl, FALSE, "%s", _("failed to get the hypervisor version"));
return FALSE;
}
if (hvVersion == 0) {
@@ -4561,7 +4561,7 @@ cmdHostname (vshControl *ctl, vshCmd *cmd ATTRIBUTE_UNUSED)
hostname = virConnectGetHostname (ctl->conn);
if (hostname == NULL) {
- vshError(ctl, FALSE, _("failed to get hostname"));
+ vshError(ctl, FALSE, "%s", _("failed to get hostname"));
return FALSE;
}
@@ -4590,7 +4590,7 @@ cmdURI (vshControl *ctl, vshCmd *cmd ATTRIBUTE_UNUSED)
uri = virConnectGetURI (ctl->conn);
if (uri == NULL) {
- vshError(ctl, FALSE, _("failed to get URI"));
+ vshError(ctl, FALSE, "%s", _("failed to get URI"));
return FALSE;
}
@@ -5016,12 +5016,12 @@ cmdDetachInterface(vshControl * ctl, vshCmd * cmd)
XML_PARSE_NOWARNING);
free(doc);
if (!xml) {
- vshError(ctl, FALSE, _("Failed to get interface information"));
+ vshError(ctl, FALSE, "%s", _("Failed to get interface information"));
goto cleanup;
}
ctxt = xmlXPathNewContext(xml);
if (!ctxt) {
- vshError(ctl, FALSE, _("Failed to get interface information"));
+ vshError(ctl, FALSE, "%s", _("Failed to get interface information"));
goto cleanup;
}
@@ -5057,12 +5057,12 @@ cmdDetachInterface(vshControl * ctl, vshCmd * cmd)
hit:
xml_buf = xmlBufferCreate();
if (!xml_buf) {
- vshError(ctl, FALSE, _("Failed to allocate memory"));
+ vshError(ctl, FALSE, "%s", _("Failed to allocate memory"));
goto cleanup;
}
if(xmlNodeDump(xml_buf, xml, obj->nodesetval->nodeTab[i], 0, 0) < 0){
- vshError(ctl, FALSE, _("Failed to create XML"));
+ vshError(ctl, FALSE, "%s", _("Failed to create XML"));
goto cleanup;
}
@@ -5298,19 +5298,19 @@ cmdDetachDisk(vshControl * ctl, vshCmd * cmd)
XML_PARSE_NOWARNING);
free(doc);
if (!xml) {
- vshError(ctl, FALSE, _("Failed to get disk information"));
+ vshError(ctl, FALSE, "%s", _("Failed to get disk information"));
goto cleanup;
}
ctxt = xmlXPathNewContext(xml);
if (!ctxt) {
- vshError(ctl, FALSE, _("Failed to get disk information"));
+ vshError(ctl, FALSE, "%s", _("Failed to get disk information"));
goto cleanup;
}
obj = xmlXPathEval(BAD_CAST "/domain/devices/disk", ctxt);
if ((obj == NULL) || (obj->type != XPATH_NODESET) ||
(obj->nodesetval == NULL) || (obj->nodesetval->nodeNr == 0)) {
- vshError(ctl, FALSE, _("Failed to get disk information"));
+ vshError(ctl, FALSE, "%s", _("Failed to get disk information"));
goto cleanup;
}
@@ -5335,12 +5335,12 @@ cmdDetachDisk(vshControl * ctl, vshCmd * cmd)
hit:
xml_buf = xmlBufferCreate();
if (!xml_buf) {
- vshError(ctl, FALSE, _("Failed to allocate memory"));
+ vshError(ctl, FALSE, "%s", _("Failed to allocate memory"));
goto cleanup;
}
if(xmlNodeDump(xml_buf, xml, obj->nodesetval->nodeTab[i], 0, 0) < 0){
- vshError(ctl, FALSE, _("Failed to create XML"));
+ vshError(ctl, FALSE, "%s", _("Failed to create XML"));
goto cleanup;
}
@@ -5742,7 +5742,7 @@ vshCommandOptDomainBy(vshControl * ctl, vshCmd * cmd, const char *optname,
int id;
if (!(n = vshCommandOptString(cmd, optname, NULL))) {
- vshError(ctl, FALSE, _("undefined domain name or id"));
+ vshError(ctl, FALSE, "%s", _("undefined domain name or id"));
return NULL;
}
@@ -5787,7 +5787,7 @@ vshCommandOptNetworkBy(vshControl * ctl, vshCmd * cmd, const char *optname,
char *n;
if (!(n = vshCommandOptString(cmd, optname, NULL))) {
- vshError(ctl, FALSE, _("undefined network name"));
+ vshError(ctl, FALSE, "%s", _("undefined network name"));
return NULL;
}
@@ -5824,7 +5824,7 @@ vshCommandOptPoolBy(vshControl * ctl, vshCmd * cmd, const char *optname,
char *n;
if (!(n = vshCommandOptString(cmd, optname, NULL))) {
- vshError(ctl, FALSE, _("undefined pool name"));
+ vshError(ctl, FALSE, "%s", _("undefined pool name"));
return NULL;
}
@@ -5865,12 +5865,12 @@ vshCommandOptVolBy(vshControl * ctl, vshCmd * cmd,
int found;
if (!(n = vshCommandOptString(cmd, optname, NULL))) {
- vshError(ctl, FALSE, _("undefined vol name"));
+ vshError(ctl, FALSE, "%s", _("undefined vol name"));
return NULL;
}
if (!(p = vshCommandOptString(cmd, pooloptname, &found)) && found) {
- vshError(ctl, FALSE, _("undefined pool name"));
+ vshError(ctl, FALSE, "%s", _("undefined pool name"));
return NULL;
}
@@ -6006,7 +6006,7 @@ vshCommandGetToken(vshControl * ctl, char *str, char **end, char **res)
sz++;
}
if (quote) {
- vshError(ctl, FALSE, _("missing \""));
+ vshError(ctl, FALSE, "%s", _("missing \""));
return VSH_TK_ERROR;
}
if (tkstr == NULL || *tkstr == '\0' || p == NULL)
@@ -6216,7 +6216,7 @@ vshConnectionUsability(vshControl * ctl, virConnectPtr conn, int showerror)
*/
if (!conn) {
if (showerror)
- vshError(ctl, FALSE, _("no valid connection"));
+ vshError(ctl, FALSE, "%s", _("no valid connection"));
return FALSE;
}
return TRUE;
@@ -6366,7 +6366,7 @@ vshInit(vshControl * ctl)
* such as "help".
*/
if (!ctl->conn) {
- vshError(ctl, FALSE, _("failed to connect to the hypervisor"));
+ vshError(ctl, FALSE, "%s", _("failed to connect to the hypervisor"));
return FALSE;
}
@@ -6397,18 +6397,20 @@ vshOpenLogFile(vshControl *ctl)
case ENOENT:
break;
default:
- vshError(ctl, TRUE, _("failed to get the log file information"));
+ vshError(ctl, TRUE, "%s",
+ _("failed to get the log file information"));
break;
}
} else {
if (!S_ISREG(st.st_mode)) {
- vshError(ctl, TRUE, _("the log path is not a file"));
+ vshError(ctl, TRUE, "%s", _("the log path is not a file"));
}
}
/* log file open */
if ((ctl->log_fd = open(ctl->logfile, LOGFILE_FLAGS, FILE_MODE)) < 0) {
- vshError(ctl, TRUE, _("failed to open the log file. check the log file path"));
+ vshError(ctl, TRUE, "%s",
+ _("failed to open the log file. check the log file path"));
}
}
@@ -6476,7 +6478,7 @@ vshOutputLogFile(vshControl *ctl, int log_level, const char *msg_format, va_list
/* write log */
if (write(ctl->log_fd, msg_buf, strlen(msg_buf)) == -1) {
vshCloseLogFile(ctl);
- vshError(ctl, FALSE, _("failed to write the log file"));
+ vshError(ctl, FALSE, "%s", _("failed to write the log file"));
}
}
@@ -6704,7 +6706,7 @@ vshUsage(vshControl * ctl, const char *cmdname)
" %-15s %s\n", cmd->name, N_(vshCmddefGetInfo(cmd,
"help")));
- fprintf(stdout,
+ fprintf(stdout, "%s",
_("\n (specify help <command> for details about the command)\n\n"));
return;
}
@@ -6891,7 +6893,7 @@ main(int argc, char **argv)
vshPrint(ctl,
_("Welcome to %s, the virtualization interactive terminal.\n\n"),
progname);
- vshPrint(ctl,
+ vshPrint(ctl, "%s",
_("Type: 'help' for help with commands\n"
" 'quit' to quit\n\n"));
}
--
1.5.4.rc1.11.gd2f82
16 years, 12 months
[Libvir] OpenVZ XML
by Mikhail A. Pokidko
On Jan 16, 2008 1:52 AM, Dave Leskovec wrote:
> 2) The Linux Container driver will be a little different than the Xen
> and OpenVZ drivers in that it doesn't have already existing
> configuration files or facilities.
Yes, thats me who took Linux Container XML for OpenVZ XML.
I better ask Shuveb.
Hi, Shuveb,
there is a whole bunch of questions!
> Quota is not implemented as yet.
As quota is not implemented yet i want to ask - what is the meaning of it?
Is it analog of diskspace and diskinodes?
And what does <gateway> sets? OpenVZ always uses fake gw 192.0.2.1
Question about <netmask> is connected with one above.
As i understand <name> means veid?
Should <name> be exactly <name> as there is vzctl set --name? I think
it can be misunderstood. Or is it a question of compatibility
--
ALTLinux Team
xmpp: solar AT solar.net.ru
16 years, 12 months
[Libvir] [PATCH] Linux-VServer support
by Daniel Hokka Zakrisson
This patch implements support for Linux-VServer guests. It is currently
missing vcpu and console support, and the necessary virsh code to support
it, but is otherwise pretty feature complete.
This is an XML dump from one of my guests:
<domain type='vserver' id='40010'>
<name>lenny</name>
<uuid>19e12957-261a-5a06-d6d0-89917d6d439f</uuid>
<memory>2048000</memory>
<os>
<hostname>lenny.test</hostname>
<type arch='i686'>vserver</type>
</os>
<devices>
<interface type='ethernet'>
<ip prefix='24' interface='dummy0' address='192.168.20.4' />
</interface>
<interface type='ethernet'>
<ip prefix='24' interface='dummy0' type='range'
address='192.168.32.100' address2='192.168.32.200'/>
</interface>
<disk type='directory' device='directory'>
<source directory='/vservers/lenny' type='auto' options='defaults'/>
<target directory='/'/>
</disk>
<disk type='directory' device='directory'>
<source directory='/srv' type='ext3' options='bind,ro'/>
<target directory='/srv'/>
</disk>
<disk type='block' device='directory'>
<source dev='/dev/mapper/test' type='ext3' options='defaults'/>
<target directory='/mnt'/>
</disk>
</devices>
</domain>
--
Daniel Hokka Zakrisson
16 years, 12 months
[Libvir] [PATCH] Keyboard layout support for QEMU/KVM
by Daniel Hokka Zakrisson
This patch adds support for qemu's -k option, which is required to run
virt-manager with a non-US keymap. Without it, keys are remapped a number
of times, ending up with a completely unusable layout.
Even with this patch I am having problems using the AltGr key, returning a
scancode of 00. This seems to be a qemu problem though.
--
Daniel Hokka Zakrisson
16 years, 12 months
[Libvir] RFC: Add a short doc with libvirt coding style guidelines
by Daniel P. Berrange
There's a few coding style guidelines we've kind of informally agreed upon
wrt to libvirt patches, and perhaps more that we ought to make decisions on.
For the benefit of people sending patches I reckon its worth writing these
down. So I'm attaching a proposed doc 'HACKING' in which we can detail the
guidelines. And yes, we don't uniformly comply with these guidelines in
all places....all the more reason to list them & fix cases where we don't
comply :-)
Thoughts.. ?
Dan.
--
|=- Red Hat, Engineering, Emerging Technologies, Boston. +1 978 392 2496 -=|
|=- Perl modules: http://search.cpan.org/~danberr/ -=|
|=- Projects: http://freshmeat.net/~danielpb/ -=|
|=- GnuPG: 7D3B9505 F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 -=|
16 years, 12 months
[Libvir] RFC: PATCH 0/5: asynchronous background jobs
by Daniel P. Berrange
We currently have a restriction that virConnectPtr objects
must only be used by a single thread. At the same time we
have a number of operations that can take a very long time.
This means that applications are pretty much forced to use
multi-threading if they want to continue to respond to user
input, and thus are also forced to use multiple virConnectPtr
objects.
This is sub-optimal because opening multiple virConnectPtr
objects may well result in the user being prompted for auth
credentials multiple times. It also doesn't provide any way
of providing progess information on the long running jobs,
nor a way to cancel them.
Thus the following series of patches introduces the concept of
an 'asynchronous background job', represented by a virJobPtr
object in the libvirt public API.
A job has an elapsed time, and may optionally include an
estimated time of completion. If it is a job with a bounded
amount of work, it will also have a percentage completion
counter. There is the ability to request cancellation of an
in progress job, and fetch any error associated with a
completed job.
The primary reason I implemented this support, is that the
storage APIs will make the current situation untennable.
Allocating storage can take a seriously long time (many
many minutes if cloning multi-GB files). This absolutely
requires progress information and an ability to cancel
an operation.
There are a number of existing APIs which can benefit from
this, hence I decided to work on this separately from the
main storage APIs. The APIs which can make use of this are
virDomainCreateLinux, virDomainCreate, virNetworkCreate,
virNetworkCreateXML, virDomainSave, virDomainRestore, and
virDomainDumpCore. For all of these we add a second variant
postfixed with 'Job' in the name, returning a virJobPtr object
This work isn't finished, but I wanted to put these patches
out for comment before going further. In particular I need
to figure out how to hook this up to the remote driver and
daemon, and deal with a few lifecycle issues. eg what todo
if a virConnectPtr object is released while a background job
is active.
With all 5 patches applied you should be able to run the
following test case:
virsh --connect test:///default save --verbose test foo
No other drivers / commands are hooked up aside from 'save'
in the 'test' driver.
Dan.
--
|=- Red Hat, Engineering, Emerging Technologies, Boston. +1 978 392 2496 -=|
|=- Perl modules: http://search.cpan.org/~danberr/ -=|
|=- Projects: http://freshmeat.net/~danielpb/ -=|
|=- GnuPG: 7D3B9505 F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 -=|
16 years, 12 months
[Libvir] [PATCH] examples.xml: Regenerate, now that *.c file names are sorted
by Jim Meyering
I ran "make distcheck" and noticed these changes
in generated-and-version-controlled files:
* docs/examples/examples.xml: Regenerate, now that *.c file
names are sorted.
Signed-off-by: Jim Meyering <meyering(a)redhat.com>
---
docs/examples/.cvsignore | 2 +-
docs/examples/examples.xml | 50 ++++++++++++++++++++++----------------------
2 files changed, 26 insertions(+), 26 deletions(-)
diff --git a/docs/examples/.cvsignore b/docs/examples/.cvsignore
index aa743cb..5f0e251 100644
--- a/docs/examples/.cvsignore
+++ b/docs/examples/.cvsignore
@@ -3,5 +3,5 @@ Makefile.in
Makefile
.deps
.libs
-suspend
info1
+suspend
diff --git a/docs/examples/examples.xml b/docs/examples/examples.xml
index af7d4b9..5e54567 100644
--- a/docs/examples/examples.xml
+++ b/docs/examples/examples.xml
@@ -1,4 +1,23 @@
<examples>
+ <example filename='info1.c'>
+ <synopsis>Extract informations about Xen domain 0</synopsis>
+ <purpose>Demonstrate the basic use of the library to connect to the hypervisor and extract domain informations.</purpose>
+ <usage>info1</usage>
+ <test>info1</test>
+ <author>Daniel Veillard</author>
+ <copy>see Copyright for the status of this software. </copy>
+ <section>Informations</section>
+ <includes>
+ </includes>
+ <uses>
+ <function line='43' file='libvirt' name='virDomainGetInfo'/>
+ <function line='53' file='libvirt' name='virDomainFree'/>
+ <function line='36' file='libvirt' name='virDomainLookupByID'/>
+ <function line='55' file='libvirt' name='virConnectClose'/>
+ <struct line='25' file='libvirt' name='virDomainInfo'/>
+ <function line='29' file='libvirt' name='virConnectOpenReadOnly'/>
+ </uses>
+ </example>
<example filename='suspend.c'>
<synopsis>Suspend a domain and then resume its execution</synopsis>
<purpose>Demonstrate the basic use of the library to suspend and resume a domain. If no id is given on the command line this script will suspend and resume the first domain found which is not Domain 0.</purpose>
@@ -21,52 +40,33 @@
<function line='100' file='libvirt' name='virConnectOpenReadOnly'/>
</uses>
</example>
- <example filename='info1.c'>
- <synopsis>Extract informations about Xen domain 0</synopsis>
- <purpose>Demonstrate the basic use of the library to connect to the hypervisor and extract domain informations.</purpose>
- <usage>info1</usage>
- <test>info1</test>
- <author>Daniel Veillard</author>
- <copy>see Copyright for the status of this software. </copy>
- <section>Informations</section>
- <includes>
- </includes>
- <uses>
- <function line='43' file='libvirt' name='virDomainGetInfo'/>
- <function line='53' file='libvirt' name='virDomainFree'/>
- <function line='36' file='libvirt' name='virDomainLookupByID'/>
- <function line='55' file='libvirt' name='virConnectClose'/>
- <struct line='25' file='libvirt' name='virDomainInfo'/>
- <function line='29' file='libvirt' name='virConnectOpenReadOnly'/>
- </uses>
- </example>
<symbols>
<symbol name='virConnectClose'>
- <ref filename='suspend.c'/>
<ref filename='info1.c'/>
+ <ref filename='suspend.c'/>
</symbol>
<symbol name='virConnectListDomains'>
<ref filename='suspend.c'/>
</symbol>
<symbol name='virConnectOpenReadOnly'>
- <ref filename='suspend.c'/>
<ref filename='info1.c'/>
+ <ref filename='suspend.c'/>
</symbol>
<symbol name='virDomainFree'>
- <ref filename='suspend.c'/>
<ref filename='info1.c'/>
+ <ref filename='suspend.c'/>
</symbol>
<symbol name='virDomainGetInfo'>
- <ref filename='suspend.c'/>
<ref filename='info1.c'/>
+ <ref filename='suspend.c'/>
</symbol>
<symbol name='virDomainInfo'>
- <ref filename='suspend.c'/>
<ref filename='info1.c'/>
+ <ref filename='suspend.c'/>
</symbol>
<symbol name='virDomainLookupByID'>
- <ref filename='suspend.c'/>
<ref filename='info1.c'/>
+ <ref filename='suspend.c'/>
</symbol>
<symbol name='virDomainResume'>
<ref filename='suspend.c'/>
--
1.5.4.rc1.11.gd2f82
16 years, 12 months
[Libvir] [PATCH] Clean up global name space in examples and tests.
by Jim Meyering
These don't really matter, other than to remove false-positives
if/when we ever automate checks for unnecessarily-global symbols.
Clean up global name space in examples and tests.
* docs/examples/suspend.c: Declare global "conn" to be static.
* tests/qemuxml2argvtest.c: Declare global "driver" to be static.
* tests/qemuxml2xmltest.c: Likewise.
diff --git a/docs/examples/suspend.c b/docs/examples/suspend.c
index 80e4da7..9ca6299 100644
--- a/docs/examples/suspend.c
+++ b/docs/examples/suspend.c
@@ -15,7 +15,7 @@
#include <stdio.h>
#include <libvirt/libvirt.h>
-virConnectPtr conn = NULL; /* the hypervisor connection */
+static virConnectPtr conn = NULL; /* the hypervisor connection */
/**
* checkDomainState:
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index d4e39b2..22e2e81 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -16,7 +16,7 @@
static char *progname;
static char *abs_top_srcdir;
-struct qemud_driver driver;
+static struct qemud_driver driver;
#define MAX_FILE 4096
diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
index c42e6fb..2ab1696 100644
--- a/tests/qemuxml2xmltest.c
+++ b/tests/qemuxml2xmltest.c
@@ -16,7 +16,7 @@
static char *progname;
static char *abs_top_srcdir;
-struct qemud_driver driver;
+static struct qemud_driver driver;
#define MAX_FILE 4096
--
1.5.4.rc1.11.gd2f82
16 years, 12 months