[libvirt] [PATCH] esx: Fix generator for string return values
by Matthias Bolte
Distinguish between strings as parameters (const char *)
and strings as return values (char **).
---
src/esx/esx_vi_generator.py | 19 +++++++++++++------
src/esx/esx_vi_methods.c | 22 ++++++++++++----------
2 files changed, 25 insertions(+), 16 deletions(-)
diff --git a/src/esx/esx_vi_generator.py b/src/esx/esx_vi_generator.py
index be96a03..f9e8e11 100755
--- a/src/esx/esx_vi_generator.py
+++ b/src/esx/esx_vi_generator.py
@@ -52,9 +52,10 @@ class Parameter:
"SessionManager" : "sessionManager",
"VirtualDiskManager" : "virtualDiskManager" }
- def __init__(self, type, name, occurrence):
+ def __init__(self, type, name, occurrence, is_return_value = False):
self.type = type
self.occurrence = occurrence
+ self.is_return_value = is_return_value
if ':' in name and name.startswith("_this"):
self.name, self.autobind_type = name.split(":")
@@ -96,7 +97,7 @@ class Parameter:
def generate_return(self, offset = 0, end_of_line = ";"):
if self.occurrence == OCCURRENCE__IGNORED:
- raise ValueError("invalid function parameteroccurrence value '%s'" % self.occurrence)
+ raise ValueError("invalid function parameter occurrence value '%s'" % self.occurrence)
else:
string = " "
string += " " * offset
@@ -130,7 +131,10 @@ class Parameter:
if self.type == "String" and \
self.occurrence not in [OCCURRENCE__REQUIRED_LIST,
OCCURRENCE__OPTIONAL_LIST]:
- return "const char *"
+ if self.is_return_value:
+ return "char *"
+ else:
+ return "const char *"
elif self.is_enum():
return "esxVI_%s " % self.type
else:
@@ -227,9 +231,11 @@ class Method:
source += "),\n"
if self.returns is None:
- source += " void, None,\n"
+ source += " void, /* nothing */, None,\n"
+ elif self.returns.type == "String":
+ source += " String, Value, %s,\n" % self.returns.get_occurrence_short_enum()
else:
- source += " %s, %s,\n" % (self.returns.type, self.returns.get_occurrence_short_enum())
+ source += " %s, /* nothing */, %s,\n" % (self.returns.type, self.returns.get_occurrence_short_enum())
source += "{\n"
@@ -1054,7 +1060,8 @@ def parse_method(block):
report_error("line %d: invalid block header" % (number))
else:
returns = Parameter(type = header_items[3], name = "output",
- occurrence = header_items[4])
+ occurrence = header_items[4],
+ is_return_value = True)
parameters = []
diff --git a/src/esx/esx_vi_methods.c b/src/esx/esx_vi_methods.c
index a00561f..5967088 100644
--- a/src/esx/esx_vi_methods.c
+++ b/src/esx/esx_vi_methods.c
@@ -67,34 +67,34 @@
-#define ESX_VI__METHOD__DESERIALIZE_OUTPUT__None(_type) \
+#define ESX_VI__METHOD__DESERIALIZE_OUTPUT__None(_type, _suffix) \
/* nothing */
-#define ESX_VI__METHOD__DESERIALIZE_OUTPUT__RequiredItem(_type) \
- if (esxVI_##_type##_Deserialize(response->node, output) < 0) { \
+#define ESX_VI__METHOD__DESERIALIZE_OUTPUT__RequiredItem(_type, _suffix) \
+ if (esxVI_##_type##_Deserialize##_suffix(response->node, output) < 0) { \
goto cleanup; \
}
-#define ESX_VI__METHOD__DESERIALIZE_OUTPUT__RequiredList(_type) \
+#define ESX_VI__METHOD__DESERIALIZE_OUTPUT__RequiredList(_type, _suffix) \
if (esxVI_##_type##_DeserializeList(response->node, output) < 0) { \
goto cleanup; \
}
-#define ESX_VI__METHOD__DESERIALIZE_OUTPUT__OptionalItem(_type) \
+#define ESX_VI__METHOD__DESERIALIZE_OUTPUT__OptionalItem(_type, _suffix) \
if (response->node != NULL && \
- esxVI_##_type##_Deserialize(response->node, output) < 0) { \
+ esxVI_##_type##_Deserialize##_suffix(response->node, output) < 0) { \
goto cleanup; \
}
-#define ESX_VI__METHOD__DESERIALIZE_OUTPUT__OptionalList(_type) \
+#define ESX_VI__METHOD__DESERIALIZE_OUTPUT__OptionalList(_type, _suffix) \
if (response->node != NULL && \
esxVI_##_type##_DeserializeList(response->node, output) < 0) { \
goto cleanup; \
@@ -103,7 +103,8 @@
#define ESX_VI__METHOD(_name, _this_from_service, _parameters, _output_type, \
- _occurrence, _validate, _serialize) \
+ _deserialize_suffix, _occurrence, _validate, \
+ _serialize) \
int \
esxVI_##_name _parameters \
{ \
@@ -139,7 +140,8 @@
goto cleanup; \
} \
\
- ESX_VI__METHOD__DESERIALIZE_OUTPUT__##_occurrence(_output_type) \
+ ESX_VI__METHOD__DESERIALIZE_OUTPUT__##_occurrence \
+ (_output_type, _deserialize_suffix) \
\
result = 0; \
\
@@ -296,7 +298,7 @@ ESX_VI__METHOD(ValidateMigration, /* special _this */,
esxVI_ManagedObjectReference *pool, /* optional */
esxVI_ManagedObjectReference *host, /* optional */
esxVI_Event **output), /* optional, list */
- Event, OptionalList,
+ Event, /* nothing */, OptionalList,
{
ESX_VI__METHOD__PARAMETER__REQUIRE(vm)
},
--
1.7.0.4
14 years, 2 months
[libvirt] Need help, how can I access to qemu-monitor with libvirt 0.8.1
by Lai Jiangshan
Hi, all
I encounter this problem when I try to send NMI to guest.
I don't know how. I think if I can access to the qemu-monitor, I can
just do this command in the qemu-monitor: "nmi <cpu#>".
But I don't know how to access to qemu-monitor, I think I can
get help here.
I noticed that the guest is started by libvirt with these parameters:
-chardev socket,id=monitor,path=/var/lib/libvirt/qemu/vm~laijs.monitor,server,nowait \
-mon chardev=monitor,mode=control
So I wrote a simple program and tried to access qemu-monitor by accessing the socket
/var/lib/libvirt/qemu/vm~laijs.monitor. It failed, because I don't know how
to send commands with "mode=control", I don't know the protocol for exchanging
data with this file.
(If I start guest with the same parameters as libvirt but using "mode=readline",
I successfully sent commands to qemu-monitor by my simple program, I just
send text commands)
I noticed that libvirt 0.8.3 supports remote protocol and arbitrary qemu commands,
but I did not found any document, how can I use it?
Thanks, Lai,
(I'm not in this email-list:libvir-list@redhat.com, please ensure my email address
in your cc-list when you reply, thanks)
14 years, 2 months
[libvirt] [PATCH] virsh: remove driver check from attach-disk command
by Ryan Harper
Virsh shouldn't check for driver support but rather let the backend handled this.
After removing the check, I can successfully attach file-based images to a qemu
VM with attach-disk.
% virsh attach-disk vm2 /images/test02.img vdc --driver qemu --type disk --subdriver raw
Disk attached successfully
This command generates the following XML:
<disk type='block' device='disk'>
<driver name='qemu' type='raw'/>
<source dev='/images/test02.img'/>
<target dev='vdc' bus='virtio'/>
<alias name='virtio-disk2'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x09' function='0x0'/>
</disk>
Signed-off-by: Ryan Harper <ryanh(a)us.ibm.com>
diff --git a/tools/virsh.c b/tools/virsh.c
index c0ee3ee..7bc33d8 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -8146,13 +8146,8 @@ cmdAttachDisk(vshControl *ctl, const vshCmd *cmd)
mode = vshCommandOptString(cmd, "mode", NULL);
if (driver) {
- if (STREQ(driver, "file") || STREQ(driver, "tap")) {
+ if (STREQ(driver, "file") || STREQ(driver, "tap"))
isFile = 1;
- } else if (STRNEQ(driver, "phy")) {
- vshError(ctl, _("No support for %s in command 'attach-disk'"),
- driver);
- goto cleanup;
- }
}
if (mode) {
--
Ryan Harper
Software Engineer; Linux Technology Center
IBM Corp., Austin, Tx
ryanh(a)us.ibm.com
14 years, 2 months
[libvirt] [PATCH] Explicitly pass uml_dir argument to user-mode-linux
by Soren Hansen
uml_dir overrides user-mode-linux's default of ~/.uml. This is needed
for a couple of different reasons:
libvirt expects this to default to virGetUserDirectory(geteuid()) +
'/.uml'. However, user-mode-linux actually uses the HOME environment
variable to determine where to look for the uml sockets, but if running
libvirtd under sudo (which I routinely do during development), $HOME is
pointing at my user's homedir, while my euid is 0, so libvirt looks in
/root.
Also (and this was my actual motivation for this patch), if HOME isn't
set at all, user-mode-linux utterly fails. Looking at the code, it seems
it's meant to emit a warning, but alas, it doesn't for some reason.
If running libvirtd from upstart, HOME is not set, so any system using
upstart will need this change.
Signed-off-by: Soren Hansen <soren(a)linux2go.dk>
---
src/uml/uml_conf.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/uml/uml_conf.c b/src/uml/uml_conf.c
index 65b06c5..4906192 100644
--- a/src/uml/uml_conf.c
+++ b/src/uml/uml_conf.c
@@ -409,7 +409,7 @@ static char *umlNextArg(char *args)
* for a given virtual machine.
*/
int umlBuildCommandLine(virConnectPtr conn,
- struct uml_driver *driver ATTRIBUTE_UNUSED,
+ struct uml_driver *driver,
virDomainObjPtr vm,
fd_set *keepfd,
const char ***retargv,
@@ -499,7 +499,6 @@ int umlBuildCommandLine(virConnectPtr conn,
ADD_ENV_COPY("LD_PRELOAD");
ADD_ENV_COPY("LD_LIBRARY_PATH");
ADD_ENV_COPY("PATH");
- ADD_ENV_COPY("HOME");
ADD_ENV_COPY("USER");
ADD_ENV_COPY("LOGNAME");
ADD_ENV_COPY("TMPDIR");
@@ -508,6 +507,7 @@ int umlBuildCommandLine(virConnectPtr conn,
//ADD_ARG_PAIR("con0", "fd:0,fd:1");
ADD_ARG_PAIR("mem", memory);
ADD_ARG_PAIR("umid", vm->def->name);
+ ADD_ARG_PAIR("uml_dir", driver->monitorDir);
if (vm->def->os.root)
ADD_ARG_PAIR("root", vm->def->os.root);
--
1.7.0.4
14 years, 2 months
[libvirt] virsh create and virsh dumpxml certain code location
by benian
Hi all,
My libivrt is libvirt-0.8.3
I would like to add "tap2" recognition when using virsh create and dumpxml,
but i could not find the certain function part that the logic of "create"
and "dumpxml" are defined,
Would anyone please give me some hints?
Thanks Very Much
Regards,
Ben
14 years, 2 months
[libvirt] [PATCH] maint: track moved file
by Eric Blake
* daemon/.gitignore: Move libvirt-guests.init...
* tools/.gitignore: ...to its new location.
---
Pushing under the obvious rule, as fallout from 2c090a555.
daemon/.gitignore | 1 -
tools/.gitignore | 1 +
2 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/daemon/.gitignore b/daemon/.gitignore
index 4475b6d..8ed7784 100644
--- a/daemon/.gitignore
+++ b/daemon/.gitignore
@@ -7,7 +7,6 @@ Makefile.in
libvirt_qemud
libvirtd
libvirtd.init
-libvirt-guests.init
libvirtd*.logrotate
libvirtd.pod
libvirtd.8
diff --git a/tools/.gitignore b/tools/.gitignore
index 51f1f66..3e34ea8 100644
--- a/tools/.gitignore
+++ b/tools/.gitignore
@@ -1,3 +1,4 @@
+libvirt-guests.init
virt-xml-validate
virt-pki-validate
*.1
--
1.7.2.2
14 years, 2 months
[libvirt] Decent How-To now on the wiki for setting up Transport Layer Security
by Justin Clift
Hi all,
For anyone that's interested in setting up TLS with libvirt, but hasn't
gotten around to it yet, there's a decent guide on the wiki now:
http://wiki.libvirt.org/page/TLSSetup
It's user focused (ie SysAdmin's), and has lots of pics explaining
concepts, plus shows what needs to be done, and shows how to do it.
Please note, it doesn't cover SASL, it's just plain host based TLS.
Very much open to feedback on it, if people have suggestions for
improvement.
Hope that helps. :)
Regards and best wishes,
Justin Clift
14 years, 2 months
[libvirt] [RFC] Memory controller exploitation in libvirt
by Nikunj A. Dadhania
Subject: [RFC] Memory controller exploitation in libvirt
Memory CGroup is a kernel feature that can be exploited effectively in the
current libvirt/qemu driver. Here is a shot at that.
At present, QEmu uses memory ballooning feature, where the memory can be
inflated/deflated as and when needed, co-operatively between the host and
the guest. There should be some mechanism where the host can have more
control over the guests memory usage. Memory CGroup provides features such
as hard-limit and soft-limit for memory, and hard-limit for swap area.
Design 1: Provide new API and XML changes for resource management
=================================================================
All the memory controller tunables are not supported with the current
abstractions provided by the libvirt API. libvirt works on various OS. This
new API will support GNU/Linux initially and as and when other platforms
starts supporting memory tunables, the interface could be enabled for
them. Adding following two function pointer to the virDriver interface.
1) domainSetMemoryParameters: which would take one or more name-value
pairs. This makes the API extensible, and agnostic to the kind of
parameters supported by various Hypervisors.
2) domainGetMemoryParameters: For getting current memory parameters
Corresponding libvirt public API:
int virDomainSetMemoryParamters (virDomainPtr domain,
virMemoryParamterPtr params,
unsigned int nparams);
int virDomainGetMemoryParamters (virDomainPtr domain,
virMemoryParamterPtr params,
unsigned int nparams);
Parameter list supported:
MemoryHardLimits (memory.limits_in_bytes) - Maximum memory
MemorySoftLimits (memory.softlimit_in_bytes) - Desired memory
MemoryMinimumGaurantee - Minimum memory required (without this amount of
memory, VM should not be started)
SwapHardLimits (memory.memsw_limit_in_bytes) - Maximum swap
SwapSoftLimits (Currently not supported by kernel) - Desired swap space
Tunables memory.limit_in_bytes, memory.softlimit_in_bytes and
memory.memsw_limit_in_bytes are provided by the memory controller in the
Linux kernel.
I am not an expert here, so just listing what new elements need to be added
to the XML schema:
<define name="resource">
<element memory>
<element memoryHardLimit/>
<element memorySoftLimit/>
<element memoryMinGaurantee/>
<element swapHardLimit/>
<element swapSoftLimit/>
</element>
</define>
Pros:
* Support all the tunables exported by the kernel
* More tunables can be added as and when required
Cons:
* Code changes would touch various levels
* Might need to redefine(changing the scope) of existing memory
API. Currently, domainSetMemory is used to set limit_in_bytes in LXC and
memory ballooning in QEmu. While the domainSetMaxMemory is not defined in
QEmu and in case of LXC it is setting the internal object's maxmem
variable.
Future:
* Later on, CPU/IO/Network controllers related tunables can be
added/enhanced along with the APIs/XML elements:
CPUHardLimit
CPUSoftLimit
CPUShare
CPUPercentage
IO_BW_Softlimit
IO_BW_Hardlimit
IO_BW_percentage
* libvirt-cim support for resource management
Design 2: Reuse the current memory APIs in libvirt
==================================================
Use memory.limit_in_bytes to tweak memory hard limits
Init - Set the memory.limit_in_bytes to maximum mem.
Claiming memory from guest:
a) Reduce balloon size
b) If the guest does not co-operate(How do we know?), reduce
memory.limit_in_bytes.
Allocating memory more than max memory: How to solve this? As we have
already set the max balloon size. We can only play within this!
Pros:
* Few changes
* Is not intrusive
Cons:
* SetMemory and SetMaxMemory usage is confusing.
* SetMemory is too generic a name, it does not cover all the tunables.
* Does not support memory softlimit
* Does not have support to reserve the memory swap region
* This solution is not extensible
IMO, "Design 1" is more generic and extensible for various memory
tuneables.
Nikunj
14 years, 2 months