# HG changeset patch
# User Dan Smith <danms(a)us.ibm.com>
# Date 1194897180 28800
# Node ID f86d7a5bfa6b597d3909eae06f367ec640fb0a2c
# Parent c7572e9cdf49a37b96375e799c7b9818ae36fd1d
Add device change support (just for memory right now)
Signed-off-by: Dan Smith <danms(a)us.ibm.com>
diff -r c7572e9cdf49 -r f86d7a5bfa6b libxkutil/device_parsing.c
--- a/libxkutil/device_parsing.c Mon Nov 12 11:07:46 2007 -0800
+++ b/libxkutil/device_parsing.c Mon Nov 12 11:53:00 2007 -0800
@@ -615,9 +615,9 @@ void cleanup_dominfo(struct domain **dom
*dominfo = NULL;
}
-static int change_device(virDomainPtr dom,
- struct virt_device *dev,
- bool attach)
+static int _change_device(virDomainPtr dom,
+ struct virt_device *dev,
+ bool attach)
{
char *xml = NULL;
int ret = 0;
@@ -648,11 +648,28 @@ static int change_device(virDomainPtr do
}
+static int change_memory(virDomainPtr dom,
+ struct virt_device *dev)
+{
+ CU_DEBUG("Changing memory of %s to %llu/%llu",
+ virDomainGetName(dom),
+ dev->dev.mem.size,
+ dev->dev.mem.maxsize);
+
+ if (virDomainSetMemory(dom, dev->dev.mem.size))
+ return 0;
+
+ if (virDomainSetMaxMemory(dom, dev->dev.mem.maxsize))
+ return 0;
+
+ 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);
+ return _change_device(dom, dev, true);
CU_DEBUG("Unhandled device type %i", dev->type);
@@ -663,7 +680,17 @@ int detach_device(virDomainPtr dom, stru
{
if ((dev->type == VIRT_DEV_NET) ||
(dev->type == VIRT_DEV_DISK))
- return change_device(dom, dev, false);
+ return _change_device(dom, dev, false);
+
+ CU_DEBUG("Unhandled device type %i", dev->type);
+
+ return 0;
+}
+
+int change_device(virDomainPtr dom, struct virt_device *dev)
+{
+ if (dev->type == VIRT_DEV_MEM)
+ return change_memory(dom, dev);
CU_DEBUG("Unhandled device type %i", dev->type);
diff -r c7572e9cdf49 -r f86d7a5bfa6b libxkutil/device_parsing.h
--- a/libxkutil/device_parsing.h Mon Nov 12 11:07:46 2007 -0800
+++ b/libxkutil/device_parsing.h Mon Nov 12 11:53:00 2007 -0800
@@ -113,6 +113,7 @@ int parse_fq_devid(char *devid, char **h
int attach_device(virDomainPtr dom, struct virt_device *dev);
int detach_device(virDomainPtr dom, struct virt_device *dev);
+int change_device(virDomainPtr dom, struct virt_device *dev);
#endif