PATCH: Cleanup conditionals from proxy driver in Xen code

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

 



The various xen drivers have alot of their code conditionally compiled using
#ifdef PROXY to avoid functions when built into the proxy. Without the proxy
this is no longer needed. There are a couple of functions that were only
used by the proxy & so can go completely.

$ diffstat .hg/patches/proxy-cpp-cleanup 
 xen_internal.c  |   24 +------------------
 xend_internal.c |   70 +++-----------------------------------------------------
 xml.c           |    2 -
 xs_internal.c   |   59 +----------------------------------------------
 4 files changed, 8 insertions(+), 147 deletions(-)

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  -=| 
diff -r 8a49caa265ec src/xen_internal.c
--- a/src/xen_internal.c	Tue Sep 18 14:29:40 2007 -0400
+++ b/src/xen_internal.c	Tue Sep 18 14:39:57 2007 -0400
@@ -618,12 +618,9 @@ typedef struct xen_op_v2_dom xen_op_v2_d
 
 #define XEN_HYPERVISOR_SOCKET "/proc/xen/privcmd"
 
-#ifndef PROXY
 static const char * xenHypervisorGetType(virConnectPtr conn);
 static unsigned long xenHypervisorGetMaxMemory(virDomainPtr domain);
-#endif
-
-#ifndef PROXY
+
 struct xenUnifiedDriver xenHypervisorDriver = {
     xenHypervisorOpen, /* open */
     xenHypervisorClose, /* close */
@@ -667,7 +664,6 @@ struct xenUnifiedDriver xenHypervisorDri
     xenHypervisorGetSchedulerParameters, /* domainGetSchedulerParameters */
     xenHypervisorSetSchedulerParameters, /* domainSetSchedulerParameters */
 };
-#endif /* !PROXY */
 
 /**
  * virXenError:
@@ -690,7 +686,6 @@ virXenError(virErrorNumber error, const 
                     errmsg, info, NULL, value, 0, errmsg, info, value);
 }
 
-#ifndef PROXY
 
 /**
  * virXenErrorFunc:
@@ -726,7 +721,6 @@ virXenErrorFunc(virErrorNumber error, co
     }
 }
 
-#endif /* PROXY */
 
 /**
  * virXenPerror:
@@ -1016,7 +1010,6 @@ virXen_getdomaininfo(int handle, int fir
 }
 
 
-#ifndef PROXY
 /**
  * xenHypervisorGetSchedulerType:
  * @domain: pointer to the Xen Hypervisor block
@@ -1741,7 +1734,6 @@ virXen_setvcpumap(int handle, int id, un
     }
     return(ret);
 }
-#endif /* !PROXY*/
 
 /**
  * virXen_getvcpusinfo:
@@ -2139,7 +2131,6 @@ xenHypervisorClose(virConnectPtr conn)
 }
 
 
-#ifndef PROXY
 /**
  * xenHypervisorGetType:
  * @conn: pointer to the Xen Hypervisor block
@@ -2159,7 +2150,6 @@ xenHypervisorGetType(virConnectPtr conn)
     }
     return("Xen");
 }
-#endif
 
 /**
  * xenHypervisorGetVersion:
@@ -2611,7 +2601,6 @@ xenHypervisorListDomains(virConnectPtr c
 }
 
 
-#ifndef PROXY
 char *
 xenHypervisorDomainGetOSType (virDomainPtr dom)
 {
@@ -2738,7 +2727,6 @@ xenHypervisorLookupDomainByUUID(virConne
     free(name);
     return ret;
 }
-#endif
 
 /**
  * xenHypervisorGetMaxVcpus:
@@ -2800,7 +2788,6 @@ xenHypervisorGetDomMaxMemory(virConnectP
     return((unsigned long) XEN_GETDOMAININFO_MAX_PAGES(dominfo) * kb_per_pages);
 }
 
-#ifndef PROXY
 /**
  * xenHypervisorGetMaxMemory:
  * @domain: a domain object or NULL
@@ -2825,7 +2812,6 @@ xenHypervisorGetMaxMemory(virDomainPtr d
 
     return(xenHypervisorGetDomMaxMemory(domain->conn, domain->id));
 }
-#endif
 
 /**
  * xenHypervisorGetDomInfo:
@@ -2937,7 +2923,6 @@ xenHypervisorGetDomainInfo(virDomainPtr 
 
 }
 
-#ifndef PROXY
 /**
  * xenHypervisorPauseDomain:
  * @domain: pointer to the domain block
@@ -3046,9 +3031,7 @@ xenHypervisorSetMaxMemory(virDomainPtr d
         return (-1);
     return (0);
 }
-#endif /* PROXY */
-
-#ifndef PROXY
+
 /**
  * xenHypervisorSetVcpus:
  * @domain: pointer to domain object
@@ -3111,7 +3094,6 @@ xenHypervisorPinVcpu(virDomainPtr domain
         return (-1);
     return (0);
 }
-#endif
 
 /**
  * virDomainGetVcpus:
@@ -3132,7 +3114,6 @@ xenHypervisorPinVcpu(virDomainPtr domain
  *
  * Returns the number of info filled in case of success, -1 in case of failure.
  */
-#ifndef PROXY
 int
 xenHypervisorGetVcpus(virDomainPtr domain, virVcpuInfoPtr info, int maxinfo,
                       unsigned char *cpumaps, int maplen)
@@ -3184,7 +3165,6 @@ xenHypervisorGetVcpus(virDomainPtr domai
     }
     return nbinfo;
 }
-#endif /* PROXY */
 
 /**
  * xenHypervisorGetVcpuMax:
diff -r 8a49caa265ec src/xend_internal.c
--- a/src/xend_internal.c	Tue Sep 18 14:29:40 2007 -0400
+++ b/src/xend_internal.c	Tue Sep 18 14:39:57 2007 -0400
@@ -47,7 +47,6 @@
 /* required for cpumap_t */
 #include <xen/dom0_ops.h>
 
-#ifndef PROXY
 static const char * xenDaemonGetType(virConnectPtr conn);
 static int xenDaemonListDomains(virConnectPtr conn, int *ids, int maxids);
 static int xenDaemonNumOfDomains(virConnectPtr conn);
@@ -61,9 +60,7 @@ static int xenDaemonDetachDevice(virDoma
 static int xenDaemonDetachDevice(virDomainPtr domain, char *xml);
 static int xenDaemonDomainCoreDump(virDomainPtr domain, const char *filename,
                                    int flags);
-#endif /* PROXY */
-
-#ifndef PROXY
+
 struct xenUnifiedDriver xenDaemonDriver = {
     xenDaemonOpen, /* open */
     xenDaemonClose, /* close */
@@ -118,7 +115,6 @@ xenDaemonInit (void)
 {
     return 0;
 }
-#endif /* !PROXY */
 
 /**
  * xend_connection_type:
@@ -473,7 +469,6 @@ xend_get(virConnectPtr xend, const char 
     return ret;
 }
 
-#ifndef PROXY
 /**
  * xend_post:
  * @xend: pointer to the Xen Daemon structure
@@ -531,7 +526,6 @@ xend_post(virConnectPtr xend, const char
 
     return ret;
 }
-#endif /* ! PROXY */
 
 
 /**
@@ -567,7 +561,6 @@ http2unix(virConnectPtr xend, int ret)
     return -1;
 }
 
-#ifndef PROXY
 /**
  * xend_op_ext2:
  * @xend: pointer to the Xen Daemon structure
@@ -676,7 +669,6 @@ xend_op_ext(virConnectPtr xend, const ch
 }
 
 #define xend_op(xend, name, key, ...) ({char error[1024]; xend_op_ext(xend, name, error, sizeof(error), key, __VA_ARGS__);})
-#endif /* ! PROXY */
 
 /**
  * sexpr_get:
@@ -791,7 +783,6 @@ sexpr_uuid(unsigned char *ptr, struct se
 }
 
 
-#ifndef PROXY
 /**
  * urlencode:
  * @string: the input URL
@@ -829,7 +820,6 @@ urlencode(const char *string)
 
     return buffer;
 }
-#endif /* ! PROXY */
 
 /* PUBLIC FUNCTIONS */
 
@@ -867,7 +857,6 @@ xenDaemonOpen_unix(virConnectPtr conn, c
     return (0);
 }
 
-#ifndef PROXY
 /**
  * xenDaemonOpen_tcp:
  * @conn: an existing virtual connection block
@@ -931,9 +920,6 @@ xend_wait_for_devices(virConnectPtr xend
 }
 
 
-#endif /* PROXY */
-
-
 /**
  * xenDaemonListDomainsOld:
  * @xend: pointer to the Xem Daemon block
@@ -991,7 +977,6 @@ xenDaemonListDomainsOld(virConnectPtr xe
     return ret;
 }
 
-#ifndef PROXY
 /**
  * xenDaemonDomainCreateLinux:
  * @xend: A xend instance
@@ -1028,7 +1013,6 @@ xenDaemonDomainCreateLinux(virConnectPtr
 
     return ret;
 }
-#endif /* ! PROXY */
 
 /**
  * xenDaemonDomainLookupByName_ids:
@@ -1132,7 +1116,6 @@ error:
 }
 
 
-#ifndef PROXY
 static int
 xend_detect_config_version(virConnectPtr conn) {
     struct sexpr *root;
@@ -1240,7 +1223,6 @@ xend_log(virConnectPtr xend, char *buffe
 {
     return http2unix(xend, xend_get(xend, "/xend/node/log", buffer, n_buffer));
 }
-#endif /* PROXY */
 
 /*****************************************************************
  ******
@@ -1869,7 +1851,6 @@ sexpr_to_xend_node_info(struct sexpr *ro
     return (0);
 }
 
-#ifndef PROXY
 /**
  * sexpr_to_domain:
  * @conn: an existing virtual connection block
@@ -1923,7 +1904,6 @@ error:
         virFreeDomain(conn, ret);
     return(NULL);
 }
-#endif /* !PROXY */
 
 /*****************************************************************
  ******
@@ -1936,7 +1916,6 @@ error:
  ******
  ******
  *****************************************************************/
-#ifndef PROXY
 /**
  * xenDaemonOpen:
  * @conn: an existing virtual connection block
@@ -2286,7 +2265,6 @@ xenDaemonDomainRestore(virConnectPtr con
     }
     return xend_op(conn, "", "op", "restore", "file", filename, NULL);
 }
-#endif /* !PROXY */
 
 /**
  * xenDaemonDomainGetMaxMemory:
@@ -2325,7 +2303,6 @@ xenDaemonDomainGetMaxMemory(virDomainPtr
     return(ret);
 }
 
-#ifndef PROXY
 /**
  * xenDaemonDomainSetMaxMemory:
  * @domain: pointer to the Domain block
@@ -2397,32 +2374,6 @@ xenDaemonDomainSetMemory(virDomainPtr do
                    "target", buf, NULL);
 }
 
-#endif /* ! PROXY */
-
-/* XXX change proxy to use Name instead of ID, then
-   dumpxml will work over proxy for inactive domains
-   and this can be removed */
-char *
-xenDaemonDomainDumpXMLByID(virConnectPtr conn, int domid)
-{
-    char *ret = NULL;
-    struct sexpr *root;
-    xenUnifiedPrivatePtr priv;
-
-    root = sexpr_get(conn, "/xend/domain/%d?detail=1", domid);
-    if (root == NULL) {
-        virXendError (conn, VIR_ERR_XEN_CALL,
-                      "xenDaemonDomainDumpXMLByID failed to find this domain");
-        return (NULL);
-    }
-
-    priv = (xenUnifiedPrivatePtr) conn->privateData;
-
-    ret = xend_parse_sexp_desc(conn, root, priv->xendConfigVersion);
-    sexpr_free(root);
-
-    return (ret);
-}
 
 char *
 xenDaemonDomainDumpXMLByName(virConnectPtr conn, const char *name)
@@ -2447,7 +2398,6 @@ xenDaemonDomainDumpXMLByName(virConnectP
 }
 
 
-#ifndef PROXY
 /**
  * xenDaemonDomainDumpXML:
  * @domain: a domain object
@@ -2474,12 +2424,8 @@ xenDaemonDomainDumpXML(virDomainPtr doma
         return(NULL);
     }
 
-    if (domain->id < 0)
-        return xenDaemonDomainDumpXMLByName(domain->conn, domain->name);
-    else
-        return xenDaemonDomainDumpXMLByID(domain->conn, domain->id);
-}
-#endif /* !PROXY */
+    return xenDaemonDomainDumpXMLByName(domain->conn, domain->name);
+}
 
 /**
  * xenDaemonDomainGetInfo:
@@ -2519,7 +2465,6 @@ xenDaemonDomainGetInfo(virDomainPtr doma
     return (ret);
 }
 
-#ifndef PROXY
 /**
  * xenDaemonLookupByName:
  * @conn: A xend instance
@@ -2552,7 +2497,6 @@ error:
     sexpr_free(root);
     return(ret);
 }
-#endif /* ! PROXY */
 
 /**
  * xenDaemonNodeGetInfo:
@@ -2586,7 +2530,6 @@ xenDaemonNodeGetInfo(virConnectPtr conn,
     return (ret);
 }
 
-#ifndef PROXY
 /**
  * xenDaemonGetType:
  * @conn: pointer to the Xen Daemon block
@@ -2606,7 +2549,6 @@ xenDaemonGetType(virConnectPtr conn)
     }
     return("XenDaemon");
 }
-#endif /* ! PROXY */
 
 /**
  * xenDaemonGetVersion:
@@ -2646,7 +2588,6 @@ xenDaemonGetVersion(virConnectPtr conn, 
     return(0);
 }
 
-#ifndef PROXY
 /**
  * xenDaemonListDomains:
  * @conn: pointer to the hypervisor connection
@@ -2725,9 +2666,7 @@ error:
 	sexpr_free(root);
     return(ret);
 }
-#endif /* ! PROXY */
-
-#ifndef PROXY
+
 /**
  * xenDaemonLookupByID:
  * @conn: pointer to the hypervisor connection
@@ -3475,7 +3414,6 @@ error:
     return(ret);
 }
 
-#endif /* ! PROXY */
 #endif /* WITH_XEN */
 
 /*
diff -r 8a49caa265ec src/xml.c
--- a/src/xml.c	Tue Sep 18 14:29:40 2007 -0400
+++ b/src/xml.c	Tue Sep 18 14:39:57 2007 -0400
@@ -25,7 +25,6 @@
 #include "buf.h"
 #include "xs_internal.h" /* for xenStoreDomainGetNetworkID */
 
-#ifndef PROXY
 /**
  * virXMLError:
  * @conn: a connection if any
@@ -1456,7 +1455,6 @@ virDomainXMLDevID(virDomainPtr domain, c
         xmlFree(attr);
     return ret;
 }
-#endif /* !PROXY */
 
 /*
  * Local variables:
diff -r 8a49caa265ec src/xs_internal.c
--- a/src/xs_internal.c	Tue Sep 18 14:29:40 2007 -0400
+++ b/src/xs_internal.c	Tue Sep 18 14:39:57 2007 -0400
@@ -33,7 +33,6 @@
 
 #define XEN_HYPERVISOR_SOCKET "/proc/xen/privcmd"
 
-#ifndef PROXY
 static char *xenStoreDomainGetOSType(virDomainPtr domain);
 
 struct xenUnifiedDriver xenStoreDriver = {
@@ -90,7 +89,6 @@ xenStoreInit ()
 {
     return 0;
 }
-#endif /* ! PROXY */
 
 /**
  * virXenStoreError:
@@ -118,7 +116,6 @@ virXenStoreError(virConnectPtr conn, vir
  *		Helper internal APIs					*
  *									*
  ************************************************************************/
-#ifndef PROXY
 /**
  * virConnectDoStoreList:
  * @conn: pointer to the hypervisor connection
@@ -144,7 +141,6 @@ virConnectDoStoreList(virConnectPtr conn
 
     return xs_directory (priv->xshandle, 0, path, nb);
 }
-#endif /* ! PROXY */
 
 /**
  * virDomainDoStoreQuery:
@@ -176,7 +172,6 @@ virDomainDoStoreQuery(virConnectPtr conn
     return xs_read(priv->xshandle, 0, &s[0], &len);
 }
 
-#ifndef PROXY
 /**
  * virDomainDoStoreWrite:
  * @domain: a domain object
@@ -302,7 +297,6 @@ virConnectCheckStoreID(virConnectPtr con
     return (0);
 }
 #endif
-#endif /* ! PROXY */
 
 /************************************************************************
  *									*
@@ -326,14 +320,10 @@ xenStoreOpen(virConnectPtr conn,
 {
     xenUnifiedPrivatePtr priv = (xenUnifiedPrivatePtr) conn->privateData;
 
-#ifdef PROXY
-    priv->xshandle = xs_daemon_open_readonly();
-#else
     if (flags & VIR_DRV_OPEN_RO)
-	priv->xshandle = xs_daemon_open_readonly();
+        priv->xshandle = xs_daemon_open_readonly();
     else
-	priv->xshandle = xs_daemon_open();
-#endif /* ! PROXY */
+        priv->xshandle = xs_daemon_open();
 
     if (priv->xshandle == NULL) {
         virXenStoreError(NULL, VIR_ERR_NO_XEN, 
@@ -369,7 +359,6 @@ xenStoreClose(virConnectPtr conn)
     return (0);
 }
 
-#ifndef PROXY
 /**
  * xenStoreGetDomainInfo:
  * @domain: pointer to the domain block
@@ -735,7 +724,6 @@ xenStoreDomainGetOSType(virDomainPtr dom
 
     return (str);
 }
-#endif /* ! PROXY */
 
 /**
  * xenStoreDomainGetVNCPort:
@@ -777,49 +765,6 @@ char *          xenStoreDomainGetConsole
 char *          xenStoreDomainGetConsolePath(virConnectPtr conn, int domid) {
   return virDomainDoStoreQuery(conn, domid, "console/tty");
 }
-
-#ifdef PROXY
-/*
- * xenStoreDomainGetOSTypeID:
- * @conn: pointer to the connection.
- * @id: the domain id
- *
- * Get the type of domain operation system.
- *
- * Returns the new string or NULL in case of error, the string must be
- *         freed by the caller.
- */
-char *
-xenStoreDomainGetOSTypeID(virConnectPtr conn, int id) {
-    char *vm, *str = NULL;
-    char query[200];
-    unsigned int len;
-    xenUnifiedPrivatePtr priv;
-
-    if (id < 0)
-        return(NULL);
-
-    priv = (xenUnifiedPrivatePtr) conn->privateData;
-    if (priv->xshandle == NULL)
-        return (NULL);
-
-    snprintf(query, 199, "/local/domain/%d/vm", id);
-    query[199] = 0;
-
-    vm = xs_read(priv->xshandle, 0, &query[0], &len);
-
-    if (vm) {
-        snprintf(query, 199, "%s/image/ostype", vm);
-	str = xs_read(priv->xshandle, 0, &query[0], &len);
-        free(vm);
-    }
-    if (str == NULL)
-        str = strdup("linux");
-
-
-    return (str);
-}
-#endif /* PROXY */
 
 /*
  * xenStoreDomainGetNetworkID:
--
Libvir-list mailing list
Libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]