Add virDomainGetAutostart(), virDomainSetAutostart(), virNetworkGetAutostart() and virNetworkSetAutostart(). Add the methods to the drivers' vtables, but don't actually implement it anywhere. Signed-off-by: Mark McLoughlin <markmc@xxxxxxxxxx> Index: libvirt/include/libvirt/libvirt.h.in =================================================================== --- libvirt.orig/include/libvirt/libvirt.h.in +++ libvirt/include/libvirt/libvirt.h.in @@ -328,6 +328,11 @@ int virConnectListDefinedDomains (virC int maxnames); int virDomainCreate (virDomainPtr domain); +int virDomainGetAutostart (virDomainPtr domain, + int *autostart); +int virDomainSetAutostart (virDomainPtr domain, + int autostart); + /** * virVcpuInfo: structure for information about a virtual CPU in a domain. */ @@ -528,6 +533,11 @@ char * virNetworkGetXMLDesc (virNetwor int flags); char * virNetworkGetBridgeName (virNetworkPtr network); +int virNetworkGetAutostart (virNetworkPtr network, + int *autostart); +int virNetworkSetAutostart (virNetworkPtr network, + int autostart); + #ifdef __cplusplus } #endif Index: libvirt/src/libvirt.c =================================================================== --- libvirt.orig/src/libvirt.c +++ libvirt/src/libvirt.c @@ -1862,6 +1862,69 @@ virDomainCreate(virDomainPtr domain) { } /** + * virDomainGetAutostart: + * @domain: a domain object + * + * Return a boolean value indicating whether the domain + * configured to be automatically started when the host + * machine boots. + * + * Returns -1 in case of error, 0 in case of success + */ +int +virDomainGetAutostart(virDomainPtr domain, + int *autostart) { + int i; + + if (!VIR_IS_DOMAIN(domain)) { + virLibDomainError(domain, VIR_ERR_INVALID_DOMAIN, __FUNCTION__); + return (-1); + } + if (!autostart) { + virLibDomainError(domain, VIR_ERR_INVALID_ARG, __FUNCTION__); + return (-1); + } + + for (i = 0;i < domain->conn->nb_drivers;i++) { + if ((domain->conn->drivers[i] != NULL) && + (domain->conn->drivers[i]->domainGetAutostart != NULL) && + (domain->conn->drivers[i]->domainGetAutostart(domain, autostart) == 0)) + return (0); + } + virLibConnError(domain->conn, VIR_ERR_CALL_FAILED, __FUNCTION__); + return (-1); +} + +/** + * virDomainSetAutostart: + * @domain: a domain object + * + * Configure the domain to be automatically started + * when the host machine boots. + * + * Returns -1 in case of error, 0 in case of success + */ +int +virDomainSetAutostart(virDomainPtr domain, + int autostart) { + int i; + + if (!VIR_IS_DOMAIN(domain)) { + virLibDomainError(domain, VIR_ERR_INVALID_DOMAIN, __FUNCTION__); + return (-1); + } + + for (i = 0;i < domain->conn->nb_drivers;i++) { + if ((domain->conn->drivers[i] != NULL) && + (domain->conn->drivers[i]->domainSetAutostart != NULL) && + (domain->conn->drivers[i]->domainSetAutostart(domain, autostart) == 0)) + return (0); + } + virLibConnError(domain->conn, VIR_ERR_CALL_FAILED, __FUNCTION__); + return (-1); +} + +/** * virDomainSetVcpus: * @domain: pointer to domain object, or NULL for Domain0 * @nvcpus: the new number of virtual CPUs for this domain @@ -2766,3 +2829,66 @@ virNetworkGetBridgeName(virNetworkPtr ne } return(ret); } + +/** + * virNetworkGetAutostart: + * @network: a network object + * + * Return a boolean value indicating whether the network + * configured to be automatically started when the host + * machine boots. + * + * Returns -1 in case of error, 0 in case of success + */ +int +virNetworkGetAutostart(virNetworkPtr network, + int *autostart) { + int i; + + if (!VIR_IS_NETWORK(network)) { + virLibNetworkError(network, VIR_ERR_INVALID_NETWORK, __FUNCTION__); + return (-1); + } + if (!autostart) { + virLibNetworkError(network, VIR_ERR_INVALID_ARG, __FUNCTION__); + return (-1); + } + + for (i = 0;i < network->conn->nb_network_drivers;i++) { + if ((network->conn->networkDrivers[i] != NULL) && + (network->conn->networkDrivers[i]->networkGetAutostart != NULL) && + (network->conn->networkDrivers[i]->networkGetAutostart(network, autostart) == 0)) + return (0); + } + virLibConnError(network->conn, VIR_ERR_CALL_FAILED, __FUNCTION__); + return (-1); +} + +/** + * virNetworkSetAutostart: + * @network: a network object + * + * Configure the network to be automatically started + * when the host machine boots. + * + * Returns -1 in case of error, 0 in case of success + */ +int +virNetworkSetAutostart(virNetworkPtr network, + int autostart) { + int i; + + if (!VIR_IS_NETWORK(network)) { + virLibNetworkError(network, VIR_ERR_INVALID_NETWORK, __FUNCTION__); + return (-1); + } + + for (i = 0;i < network->conn->nb_network_drivers;i++) { + if ((network->conn->networkDrivers[i] != NULL) && + (network->conn->networkDrivers[i]->networkSetAutostart != NULL) && + (network->conn->networkDrivers[i]->networkSetAutostart(network, autostart) == 0)) + return (0); + } + virLibConnError(network->conn, VIR_ERR_CALL_FAILED, __FUNCTION__); + return (-1); +} Index: libvirt/src/driver.h =================================================================== --- libvirt.orig/src/driver.h +++ libvirt/src/driver.h @@ -134,6 +134,12 @@ typedef int typedef int (*virDrvDomainDetachDevice) (virDomainPtr domain, char *xml); +typedef int + (*virDrvDomainGetAutostart) (virDomainPtr domain, + int *autostart); +typedef int + (*virDrvDomainSetAutostart) (virDomainPtr domain, + int autostart); typedef struct _virDriver virDriver; typedef virDriver *virDriverPtr; @@ -183,6 +189,8 @@ struct _virDriver { virDrvDomainUndefine domainUndefine; virDrvDomainAttachDevice domainAttachDevice; virDrvDomainDetachDevice domainDetachDevice; + virDrvDomainGetAutostart domainGetAutostart; + virDrvDomainSetAutostart domainSetAutostart; }; typedef int @@ -219,6 +227,13 @@ typedef char * int flags); typedef char * (*virDrvNetworkGetBridgeName) (virNetworkPtr network); +typedef int + (*virDrvNetworkGetAutostart) (virNetworkPtr network, + int *autostart); +typedef int + (*virDrvNetworkSetAutostart) (virNetworkPtr network, + int autostart); + typedef struct _virNetworkDriver virNetworkDriver; typedef virNetworkDriver *virNetworkDriverPtr; @@ -245,6 +260,8 @@ struct _virNetworkDriver { virDrvNetworkDestroy networkDestroy; virDrvNetworkDumpXML networkDumpXML; virDrvNetworkGetBridgeName networkGetBridgeName; + virDrvNetworkGetAutostart networkGetAutostart; + virDrvNetworkSetAutostart networkSetAutostart; }; Index: libvirt/src/proxy_internal.c =================================================================== --- libvirt.orig/src/proxy_internal.c +++ libvirt/src/proxy_internal.c @@ -81,6 +81,8 @@ static virDriver xenProxyDriver = { NULL, /* domainUndefine */ NULL, /* domainAttachDevice */ NULL, /* domainDetachDevice */ + NULL, /* domainGetAutostart */ + NULL, /* domainSetAutostart */ }; /** Index: libvirt/src/qemu_internal.c =================================================================== --- libvirt.orig/src/qemu_internal.c +++ libvirt/src/qemu_internal.c @@ -1132,6 +1132,8 @@ static virDriver qemuDriver = { qemuUndefine, /* domainUndefine */ NULL, /* domainAttachDevice */ NULL, /* domainDetachDevice */ + NULL, /* domainGetAutostart */ + NULL, /* domainSetAutostart */ }; static virNetworkDriver qemuNetworkDriver = { @@ -1150,6 +1152,8 @@ static virNetworkDriver qemuNetworkDrive qemuNetworkDestroy, /* networkDestroy */ qemuNetworkDumpXML, /* networkDumpXML */ qemuNetworkGetBridgeName, /* networkGetBridgeName */ + NULL, /* networkGetAutostart */ + NULL, /* networkSetAutostart */ }; void qemuRegister(void) { Index: libvirt/src/test.c =================================================================== --- libvirt.orig/src/test.c +++ libvirt/src/test.c @@ -125,6 +125,8 @@ static virDriver testDriver = { testDomainUndefine, /* domainUndefine */ NULL, /* domainAttachDevice */ NULL, /* domainDetachDevice */ + NULL, /* domainGetAutostart */ + NULL, /* domainSetAutostart */ }; typedef struct _testDev { Index: libvirt/src/xen_internal.c =================================================================== --- libvirt.orig/src/xen_internal.c +++ libvirt/src/xen_internal.c @@ -454,6 +454,8 @@ static virDriver xenHypervisorDriver = { NULL, /* domainUndefine */ NULL, /* domainAttachDevice */ NULL, /* domainDetachDevice */ + NULL, /* domainGetAutostart */ + NULL, /* domainSetAutostart */ }; #endif /* !PROXY */ Index: libvirt/src/xend_internal.c =================================================================== --- libvirt.orig/src/xend_internal.c +++ libvirt/src/xend_internal.c @@ -96,7 +96,9 @@ static virDriver xenDaemonDriver = { xenDaemonDomainDefineXML, /* domainDefineXML */ xenDaemonDomainUndefine, /* domainUndefine */ xenDaemonAttachDevice, /* domainAttachDevice */ - xenDaemonDetachDevice /* domainDetachDevice */ + xenDaemonDetachDevice, /* domainDetachDevice */ + NULL, /* domainGetAutostart */ + NULL, /* domainSetAutostart */ }; /** Index: libvirt/src/xm_internal.c =================================================================== --- libvirt.orig/src/xm_internal.c +++ libvirt/src/xm_internal.c @@ -104,6 +104,8 @@ static virDriver xenXMDriver = { xenXMDomainUndefine, /* domainUndefine */ NULL, /* domainAttachDevice */ NULL, /* domainDetachDevice */ + NULL, /* domainGetAutostart */ + NULL, /* domainSetAutostart */ }; static void Index: libvirt/src/xs_internal.c =================================================================== --- libvirt.orig/src/xs_internal.c +++ libvirt/src/xs_internal.c @@ -75,6 +75,8 @@ static virDriver xenStoreDriver = { NULL, /* domainUndefine */ NULL, /* domainAttachDevice */ NULL, /* domainDetachDevice */ + NULL, /* domainGetAutostart */ + NULL, /* domainSetAutostart */ }; /** Index: libvirt/src/libvirt_sym.version =================================================================== --- libvirt.orig/src/libvirt_sym.version +++ libvirt/src/libvirt_sym.version @@ -37,6 +37,8 @@ virConnectListDefinedDomains; virConnectNumOfDefinedDomains; virDomainUndefine; + virDomainGetAutostart; + virDomainSetAutostart; virGetVersion; virCopyLastError; virConnSetErrorFunc; @@ -76,6 +78,8 @@ virNetworkGetUUIDString; virNetworkGetXMLDesc; virNetworkGetBridgeName; + virNetworkGetAutostart; + virNetworkSetAutostart; local: *; }; --