[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[Libvir] PATCH: Fix const-ness for attach/detach device APIs



virDomainAttachDevice and virDomainDetachDevice both take a char * for the
XML description, but this is mistakenly not declared to be const. This 
patch fixes the public header files & all the internal drivers. NB, yes this
is in the public API, no it won't break any apps since these are input
params only.

Regards,
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  -=| 
Index: src/driver.h
===================================================================
RCS file: /data/cvs/libvirt/src/driver.h,v
retrieving revision 1.37
diff -u -p -r1.37 driver.h
--- src/driver.h	30 Sep 2007 13:09:07 -0000	1.37
+++ src/driver.h	13 Oct 2007 02:46:19 -0000
@@ -184,10 +184,10 @@ typedef int
 	(*virDrvDomainGetMaxVcpus)	(virDomainPtr domain);
 typedef int
 	(*virDrvDomainAttachDevice)	(virDomainPtr domain,
-					 char *xml);
+					 const char *xml);
 typedef int
 	(*virDrvDomainDetachDevice)	(virDomainPtr domain,
-					 char *xml);
+					 const char *xml);
 typedef int
 	(*virDrvDomainGetAutostart)	(virDomainPtr domain,
 					 int *autostart);
Index: src/libvirt.c
===================================================================
RCS file: /data/cvs/libvirt/src/libvirt.c,v
retrieving revision 1.102
diff -u -p -r1.102 libvirt.c
--- src/libvirt.c	30 Sep 2007 13:17:45 -0000	1.102
+++ src/libvirt.c	13 Oct 2007 02:46:21 -0000
@@ -2602,7 +2602,7 @@ virDomainGetMaxVcpus(virDomainPtr domain
  * Returns 0 in case of success, -1 in case of failure.
  */
 int
-virDomainAttachDevice(virDomainPtr domain, char *xml)
+virDomainAttachDevice(virDomainPtr domain, const char *xml)
 {
     virConnectPtr conn;
     DEBUG("domain=%p, xml=%s", domain, xml);
@@ -2634,7 +2634,7 @@ virDomainAttachDevice(virDomainPtr domai
  * Returns 0 in case of success, -1 in case of failure.
  */
 int
-virDomainDetachDevice(virDomainPtr domain, char *xml)
+virDomainDetachDevice(virDomainPtr domain, const char *xml)
 {
     virConnectPtr conn;
     DEBUG("domain=%p, xml=%s", domain, xml);
Index: src/remote_internal.c
===================================================================
RCS file: /data/cvs/libvirt/src/remote_internal.c,v
retrieving revision 1.28
diff -u -p -r1.28 remote_internal.c
--- src/remote_internal.c	28 Sep 2007 14:28:13 -0000	1.28
+++ src/remote_internal.c	13 Oct 2007 02:46:27 -0000
@@ -2089,13 +2089,13 @@ remoteDomainUndefine (virDomainPtr domai
 }
 
 static int
-remoteDomainAttachDevice (virDomainPtr domain, char *xml)
+remoteDomainAttachDevice (virDomainPtr domain, const char *xml)
 {
     remote_domain_attach_device_args args;
     GET_PRIVATE (domain->conn, -1);
 
     make_nonnull_domain (&args.dom, domain);
-    args.xml = xml;
+    args.xml = (char *) xml;
 
     if (call (domain->conn, priv, 0, REMOTE_PROC_DOMAIN_ATTACH_DEVICE,
               (xdrproc_t) xdr_remote_domain_attach_device_args, (char *) &args,
@@ -2106,13 +2106,13 @@ remoteDomainAttachDevice (virDomainPtr d
 }
 
 static int
-remoteDomainDetachDevice (virDomainPtr domain, char *xml)
+remoteDomainDetachDevice (virDomainPtr domain, const char *xml)
 {
     remote_domain_detach_device_args args;
     GET_PRIVATE (domain->conn, -1);
 
     make_nonnull_domain (&args.dom, domain);
-    args.xml = xml;
+    args.xml = (char *) xml;
 
     if (call (domain->conn, priv, 0, REMOTE_PROC_DOMAIN_DETACH_DEVICE,
               (xdrproc_t) xdr_remote_domain_detach_device_args, (char *) &args,
Index: src/xen_unified.c
===================================================================
RCS file: /data/cvs/libvirt/src/xen_unified.c,v
retrieving revision 1.23
diff -u -p -r1.23 xen_unified.c
--- src/xen_unified.c	30 Sep 2007 13:09:07 -0000	1.23
+++ src/xen_unified.c	13 Oct 2007 02:46:28 -0000
@@ -948,7 +948,7 @@ xenUnifiedDomainUndefine (virDomainPtr d
 }
 
 static int
-xenUnifiedDomainAttachDevice (virDomainPtr dom, char *xml)
+xenUnifiedDomainAttachDevice (virDomainPtr dom, const char *xml)
 {
     GET_PRIVATE(dom->conn);
     int i;
@@ -962,7 +962,7 @@ xenUnifiedDomainAttachDevice (virDomainP
 }
 
 static int
-xenUnifiedDomainDetachDevice (virDomainPtr dom, char *xml)
+xenUnifiedDomainDetachDevice (virDomainPtr dom, const char *xml)
 {
     GET_PRIVATE(dom->conn);
     int i;
Index: src/xend_internal.c
===================================================================
RCS file: /data/cvs/libvirt/src/xend_internal.c,v
retrieving revision 1.147
diff -u -p -r1.147 xend_internal.c
--- src/xend_internal.c	8 Oct 2007 15:02:48 -0000	1.147
+++ src/xend_internal.c	13 Oct 2007 02:46:31 -0000
@@ -58,8 +58,8 @@ static virDomainPtr xenDaemonCreateLinux
                                          const char *xmlDesc,
 					 unsigned int flags);
 static char *xenDaemonDomainGetOSType(virDomainPtr domain);
-static int xenDaemonAttachDevice(virDomainPtr domain, char *xml);
-static int xenDaemonDetachDevice(virDomainPtr domain, char *xml);
+static int xenDaemonAttachDevice(virDomainPtr domain, const char *xml);
+static int xenDaemonDetachDevice(virDomainPtr domain, const char *xml);
 static int xenDaemonDomainCoreDump(virDomainPtr domain, const char *filename,
                                    int flags);
 #endif /* PROXY */
@@ -3337,7 +3337,7 @@ xenDaemonCreateLinux(virConnectPtr conn,
  * Returns 0 in case of success, -1 in case of failure.
  */
 static int
-xenDaemonAttachDevice(virDomainPtr domain, char *xml)
+xenDaemonAttachDevice(virDomainPtr domain, const char *xml)
 {
     char *sexpr, *conf, *str;
     int hvm = 0, ret;
@@ -3396,7 +3396,7 @@ xenDaemonAttachDevice(virDomainPtr domai
  * Returns 0 in case of success, -1 in case of failure.
  */
 static int
-xenDaemonDetachDevice(virDomainPtr domain, char *xml)
+xenDaemonDetachDevice(virDomainPtr domain, const char *xml)
 {
     char class[8], ref[80];
 
Index: src/xml.c
===================================================================
RCS file: /data/cvs/libvirt/src/xml.c,v
retrieving revision 1.91
diff -u -p -r1.91 xml.c
--- src/xml.c	10 Oct 2007 17:41:06 -0000	1.91
+++ src/xml.c	13 Oct 2007 02:46:31 -0000
@@ -1335,7 +1335,7 @@ virDomainParseXMLDesc(virConnectPtr conn
  *         the caller must free() the returned value.
  */
 char *
-virParseXMLDevice(virConnectPtr conn, char *xmldesc, int hvm, int xendConfigVersion)
+virParseXMLDevice(virConnectPtr conn, const char *xmldesc, int hvm, int xendConfigVersion)
 {
     xmlDocPtr xml = NULL;
     xmlNodePtr node;
@@ -1396,7 +1396,7 @@ virParseXMLDevice(virConnectPtr conn, ch
  * Returns 0 in case of success, -1 in case of failure.
  */
 int
-virDomainXMLDevID(virDomainPtr domain, char *xmldesc, char *class, char *ref, int ref_len)
+virDomainXMLDevID(virDomainPtr domain, const char *xmldesc, char *class, char *ref, int ref_len)
 {
     xmlDocPtr xml = NULL;
     xmlNodePtr node, cur;
Index: src/xml.h
===================================================================
RCS file: /data/cvs/libvirt/src/xml.h,v
retrieving revision 1.17
diff -u -p -r1.17 xml.h
--- src/xml.h	12 Sep 2007 15:41:51 -0000	1.17
+++ src/xml.h	13 Oct 2007 02:46:32 -0000
@@ -32,8 +32,8 @@ int		virXPathNodeSet	(const char *xpath,
 				 xmlNodePtr **list);
 
 char *virDomainParseXMLDesc(virConnectPtr conn, const char *xmldesc, char **name, int xendConfigVersion);
-char *virParseXMLDevice(virConnectPtr conn, char *xmldesc, int hvm, int xendConfigVersion);
-  int virDomainXMLDevID(virDomainPtr domain, char *xmldesc, char *class, char *ref, int ref_len);
+char *virParseXMLDevice(virConnectPtr conn, const char *xmldesc, int hvm, int xendConfigVersion);
+  int virDomainXMLDevID(virDomainPtr domain, const char *xmldesc, char *class, char *ref, int ref_len);
 
 #ifdef __cplusplus
 }
Index: include/libvirt/libvirt.h
===================================================================
RCS file: /data/cvs/libvirt/include/libvirt/libvirt.h,v
retrieving revision 1.58
diff -u -p -r1.58 libvirt.h
--- include/libvirt/libvirt.h	30 Sep 2007 21:09:29 -0000	1.58
+++ include/libvirt/libvirt.h	13 Oct 2007 02:46:32 -0000
@@ -591,8 +591,8 @@ int			virDomainGetVcpus	(virDomainPtr do
  */
 #define VIR_GET_CPUMAP(cpumaps,maplen,vcpu)	&(cpumaps[(vcpu)*(maplen)])
 
-int virDomainAttachDevice(virDomainPtr domain, char *xml);
-int virDomainDetachDevice(virDomainPtr domain, char *xml);
+int virDomainAttachDevice(virDomainPtr domain, const char *xml);
+int virDomainDetachDevice(virDomainPtr domain, const char *xml);
 
 /*
  * NUMA support
Index: include/libvirt/libvirt.h.in
===================================================================
RCS file: /data/cvs/libvirt/include/libvirt/libvirt.h.in,v
retrieving revision 1.36
diff -u -p -r1.36 libvirt.h.in
--- include/libvirt/libvirt.h.in	30 Sep 2007 13:09:07 -0000	1.36
+++ include/libvirt/libvirt.h.in	13 Oct 2007 02:46:32 -0000
@@ -591,8 +591,8 @@ int			virDomainGetVcpus	(virDomainPtr do
  */
 #define VIR_GET_CPUMAP(cpumaps,maplen,vcpu)	&(cpumaps[(vcpu)*(maplen)])
 
-int virDomainAttachDevice(virDomainPtr domain, char *xml);
-int virDomainDetachDevice(virDomainPtr domain, char *xml);
+int virDomainAttachDevice(virDomainPtr domain, const char *xml);
+int virDomainDetachDevice(virDomainPtr domain, const char *xml);
 
 /*
  * NUMA support

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]