[PATCH] (#2) Add dynamic VCPU adjustments
by Dan Smith
# HG changeset patch
# User Dan Smith <danms(a)us.ibm.com>
# Date 1201101678 28800
# Node ID 8a5a12f5003b1e564fe21f29001a2843139614c3
# Parent 47438edf32be70e65bdb814ab609a70304fad2f4
(#2) Add dynamic VCPU adjustments
Changes:
- Removed stupidity from last patch
Signed-off-by: Dan Smith <danms(a)us.ibm.com>
diff -r 47438edf32be -r 8a5a12f5003b libxkutil/device_parsing.c
--- a/libxkutil/device_parsing.c Tue Jan 22 10:55:59 2008 -0800
+++ b/libxkutil/device_parsing.c Wed Jan 23 07:21:18 2008 -0800
@@ -897,11 +897,40 @@ static int change_memory(virDomainPtr do
return 1;
}
+static int change_vcpus(virDomainPtr dom, int delta)
+{
+ int ret;
+ virDomainInfo info;
+
+ ret = virDomainGetInfo(dom, &info);
+ if (ret == -1) {
+ CU_DEBUG("Failed to get domain info for %s",
+ virDomainGetName(dom));
+ return 0;
+ }
+
+ ret = virDomainSetVcpus(dom, info.nrVirtCpu + delta);
+ if (ret == -1) {
+ CU_DEBUG("Failed to set domain vcpus to %i",
+ info.nrVirtCpu + delta);
+ return 0;
+ }
+
+ CU_DEBUG("Changed %s vcpus from %i to %i",
+ virDomainGetName(dom),
+ info.nrVirtCpu,
+ info.nrVirtCpu + delta);
+
+ return 1;
+}
+
int attach_device(virDomainPtr dom, struct virt_device *dev)
{
if ((dev->type == VIRT_DEV_NET) ||
(dev->type == VIRT_DEV_DISK))
return _change_device(dom, dev, true);
+ else if (dev->type == VIRT_DEV_VCPU)
+ return change_vcpus(dom, 1);
CU_DEBUG("Unhandled device type %i", dev->type);
@@ -913,6 +942,8 @@ int detach_device(virDomainPtr dom, stru
if ((dev->type == VIRT_DEV_NET) ||
(dev->type == VIRT_DEV_DISK))
return _change_device(dom, dev, false);
+ else if (dev->type == VIRT_DEV_VCPU)
+ return change_vcpus(dom, -1);
CU_DEBUG("Unhandled device type %i", dev->type);
16 years, 9 months
about 'CreationClassName' key in VirtualSystemIsMigratableToHost method
by Guo Lian Yun
Hi,
As a reference, ComputerSystem defined as one parameter of
VirtualSystemIsMigratableToHost method,
which is parsed by passing two keys to CIMInstanceName. Below is a test
example segment.
cs_ref = CIMInstanceName(classname, keybindings = {
'Name':test_dom,
'CreationClassName':classname})
service.VirtualSystemIsMigratableToHost(ComputerSystem=cs_ref,
DestinationHost=options.ip)
If the "Name" key is set "Wrong", it will report expected error "Missing
key (Name) in ComputerSystem".
Then does the other key "CreationClassName" need to verify also? At now,
either wrong key name
or wrong value of CreationClassName, such as "CreationClassName!@#$$$"
instead of "CreationClassName",
it can still return expected result. So is it a provider's bug?
Do we need to add some verification of "CreationClassName" key in provider
code below? Thanks!
static CMPIStatus vs_migratable_host(CMPIMethodMI *self,
const CMPIContext *ctx,
const CMPIResult *results,
const CMPIObjectPath *ref,
const CMPIArgs *argsin,
CMPIArgs *argsout)
{
CMPIStatus s;
const char *dhost = NULL;
CMPIObjectPath *system;
const char *name = NULL;
cu_get_str_arg(argsin, "DestinationHost", &dhost);
cu_get_ref_arg(argsin, "ComputerSystem", &system);
if (cu_get_str_path(system, "Name", &name) != CMPI_RC_OK) {
cu_statusf(_BROKER, &s,
CMPI_RC_ERR_FAILED,
"Missing key (Name) in ComputerSystem");
METHOD_RETURN(results, 1);
return s;
}
return vs_migratable(ref, name, dhost, results);
}
Best,
Regards
Daisy Guo Lian Yun
E-mail: yunguol(a)cn.ibm.com
IBM China Development Lab, Shanghai, China
TEL: (86)-21-61008057
16 years, 9 months
[PATCH] Make CS.RequestStateChange() agree to proceed if RUNNING|BLOCKED
by Dan Smith
# HG changeset patch
# User Dan Smith <danms(a)us.ibm.com>
# Date 1201026051 28800
# Node ID c92db5f8d2b108163d75b32f906c7b55fa4f2854
# Parent 335e7862efa1f3cffce393e684179ec6cc8ee4a4
Make CS.RequestStateChange() agree to proceed if RUNNING|BLOCKED
This is an interesting Xen quirk propagated through libvirt. For the
most part, RUNNING and BLOCKED are the same thing to us.
Signed-off-by: Dan Smith <danms(a)us.ibm.com>
diff -r 335e7862efa1 -r c92db5f8d2b1 src/Virt_ComputerSystem.c
--- a/src/Virt_ComputerSystem.c Fri Jan 18 09:14:17 2008 -0800
+++ b/src/Virt_ComputerSystem.c Tue Jan 22 10:20:51 2008 -0800
@@ -512,6 +512,7 @@ static CMPIStatus state_change_disable(v
switch (info->state) {
case VIR_DOMAIN_RUNNING:
+ case VIR_DOMAIN_BLOCKED:
CU_DEBUG("Stop domain");
ret = virDomainShutdown(dom);
break;
@@ -537,6 +538,7 @@ static CMPIStatus state_change_pause(vir
switch (info->state) {
case VIR_DOMAIN_RUNNING:
+ case VIR_DOMAIN_BLOCKED:
CU_DEBUG("Pause domain");
ret = virDomainSuspend(dom);
break;
@@ -561,6 +563,7 @@ static CMPIStatus state_change_reboot(vi
switch (info->state) {
case VIR_DOMAIN_RUNNING:
+ case VIR_DOMAIN_BLOCKED:
CU_DEBUG("Reboot domain");
ret = virDomainReboot(dom, 0);
break;
@@ -585,6 +588,7 @@ static CMPIStatus state_change_reset(vir
switch (info->state) {
case VIR_DOMAIN_RUNNING:
+ case VIR_DOMAIN_BLOCKED:
CU_DEBUG("Reset domain");
ret = domain_reset(dom);
break;
16 years, 9 months
[PATCH 0 of 2] Virt_ComputerSystemIndication
by Jay Gagnon
This one stops leaking some of the memory from the ind_args struct and adds a little more verbosity to some error messages per Dan's request. I didn't add system name to the "Failed to create ind" one, because it was not readily available already and the extra code to get it didn't seem worth it, but I put in all the information that is available at that point.
16 years, 9 months
[PATCH] Add dynamic VCPU adjustments
by Dan Smith
# HG changeset patch
# User Dan Smith <danms(a)us.ibm.com>
# Date 1201029734 28800
# Node ID 84f80a8040eb29109d0fce50b582582527c2e50e
# Parent 47438edf32be70e65bdb814ab609a70304fad2f4
Add dynamic VCPU adjustments
Signed-off-by: Dan Smith <danms(a)us.ibm.com>
diff -r 47438edf32be -r 84f80a8040eb libxkutil/device_parsing.c
--- a/libxkutil/device_parsing.c Tue Jan 22 10:55:59 2008 -0800
+++ b/libxkutil/device_parsing.c Tue Jan 22 11:22:14 2008 -0800
@@ -897,11 +897,38 @@ static int change_memory(virDomainPtr do
return 1;
}
+static int change_vcpus(virDomainPtr dom, int delta)
+{
+ int count = 32;
+ int max;
+ virVcpuInfoPtr foo;
+
+ /* This is retarded, but I don't think there's an API to
+ * expose the total VCPU number otherwise
+ */
+ for (max = count; max == count; max += 32) {
+ foo = calloc(max, sizeof(*foo));
+ count = virDomainGetVcpus(dom, foo, max, NULL, 0);
+ free(foo);
+ }
+
+ CU_DEBUG("Changing VCPUs of %s from %i to %i",
+ virDomainGetName(dom),
+ count,
+ count + delta);
+
+ virDomainSetVcpus(dom, count + delta);
+
+ return 1;
+}
+
int attach_device(virDomainPtr dom, struct virt_device *dev)
{
if ((dev->type == VIRT_DEV_NET) ||
(dev->type == VIRT_DEV_DISK))
return _change_device(dom, dev, true);
+ else if (dev->type == VIRT_DEV_VCPU)
+ return change_vcpus(dom, 1);
CU_DEBUG("Unhandled device type %i", dev->type);
@@ -913,6 +940,8 @@ int detach_device(virDomainPtr dom, stru
if ((dev->type == VIRT_DEV_NET) ||
(dev->type == VIRT_DEV_DISK))
return _change_device(dom, dev, false);
+ else if (dev->type == VIRT_DEV_VCPU)
+ return change_vcpus(dom, -1);
CU_DEBUG("Unhandled device type %i", dev->type);
16 years, 9 months
[PATCH] (#2) Make virt_device_dup() not crash the CIMOM if a field is NULL
by Dan Smith
# HG changeset patch
# User Dan Smith <danms(a)us.ibm.com>
# Date 1201036025 28800
# Node ID 93454e6c0dfe66eedc679e8f839b523991ad3b10
# Parent 84f80a8040eb29109d0fce50b582582527c2e50e
(#2) Make virt_device_dup() not crash the CIMOM if a field is NULL
Changes since last time:
- Clear the new device so we don't leave garbage if the source
has a NULL field
Signed-off-by: Dan Smith <danms(a)us.ibm.com>
diff -r 84f80a8040eb -r 93454e6c0dfe libxkutil/device_parsing.c
--- a/libxkutil/device_parsing.c Tue Jan 22 11:22:14 2008 -0800
+++ b/libxkutil/device_parsing.c Tue Jan 22 13:07:05 2008 -0800
@@ -519,13 +519,16 @@ static int parse_devices(const char *xml
return count;
}
-#define DUP_FIELD(d, s, f) ((d)->f = strdup((s)->f))
+#define DUP_FIELD(d, s, f) do { \
+ if ((s)->f != NULL) \
+ (d)->f = strdup((s)->f); \
+ } while (0);
struct virt_device *virt_device_dup(struct virt_device *_dev)
{
struct virt_device *dev;
- dev = malloc(sizeof(*dev));
+ dev = calloc(1, sizeof(*dev));
if (dev == NULL)
return NULL;
16 years, 9 months
[PATCH] Make virt_device_dup() not crash the CIMOM if a field is NULL
by Dan Smith
# HG changeset patch
# User Dan Smith <danms(a)us.ibm.com>
# Date 1201034878 28800
# Node ID d4fb7d17d93660af5e367dfed0a11d35007aea39
# Parent 84f80a8040eb29109d0fce50b582582527c2e50e
Make virt_device_dup() not crash the CIMOM if a field is NULL
Signed-off-by: Dan Smith <danms(a)us.ibm.com>
diff -r 84f80a8040eb -r d4fb7d17d936 libxkutil/device_parsing.c
--- a/libxkutil/device_parsing.c Tue Jan 22 11:22:14 2008 -0800
+++ b/libxkutil/device_parsing.c Tue Jan 22 12:47:58 2008 -0800
@@ -519,7 +519,10 @@ static int parse_devices(const char *xml
return count;
}
-#define DUP_FIELD(d, s, f) ((d)->f = strdup((s)->f))
+#define DUP_FIELD(d, s, f) do { \
+ if ((s)->f != NULL) \
+ (d)->f = strdup((s)->f); \
+ } while (0);
struct virt_device *virt_device_dup(struct virt_device *_dev)
{
16 years, 9 months
[PATCH 0 of 2] #2 Virt_ComputerSystemIndication
by Jay Gagnon
Another crack at the integration of CSMI and CSI. It appears that a lot of work went into not much change from the last set really. This new set really just fixes a couple of very annoying bugs from the old one, as detailed in the individual patches.
16 years, 9 months