mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-22 03:12:22 +00:00
Implement autostart for XM driver
This commit is contained in:
parent
1eeceaa649
commit
8f7e086f19
@ -1,3 +1,12 @@
|
||||
Tue Nov 25 10:49:40 GMT 2008 Daniel P. Berrange <berrange@redhat.com>
|
||||
|
||||
* src/Makefile.am: Remove unneccessary $(builddir) usage which
|
||||
breaks on older automake. Remove duplicate CFLAGS from merge
|
||||
error
|
||||
* src/xen_unified.c: Wire up XM driver for autostart
|
||||
* src/xm_internal.h, src/xm_internal.c: Implement domain
|
||||
autostart functions for /etc/xen/auto
|
||||
|
||||
Tue Nov 25 10:43:40 GMT 2008 Daniel P. Berrange <berrange@redhat.com>
|
||||
|
||||
Xen domain lifecycle events (Ben Guthro & Daniel Berrange)
|
||||
|
@ -192,8 +192,6 @@ libvirt_driver_la_SOURCES = \
|
||||
libvirt_driver_la_CFLAGS = $(XEN_CFLAGS)
|
||||
libvirt_driver_la_LDFLAGS = $(XEN_LIBS)
|
||||
|
||||
libvirt_driver_la_CFLAGS = $(XEN_CFLAGS)
|
||||
|
||||
if WITH_TEST
|
||||
if WITH_DRIVER_MODULES
|
||||
mod_LTLIBRARIES += libvirt_driver_test.la
|
||||
@ -397,14 +395,14 @@ EXTRA_DIST += \
|
||||
libvirt_la_SOURCES =
|
||||
libvirt_la_LIBADD += \
|
||||
@CYGWIN_EXTRA_LIBADD@ ../gnulib/lib/libgnu.la
|
||||
libvirt_la_LDFLAGS = -Wl,--version-script=$(builddir)/libvirt_sym.version \
|
||||
libvirt_la_LDFLAGS = -Wl,--version-script=libvirt_sym.version \
|
||||
-version-info @LIBVIRT_VERSION_INFO@ \
|
||||
$(COVERAGE_CFLAGS:-f%=-Wc,-f%) \
|
||||
$(LIBXML_LIBS) $(SELINUX_LIBS) \
|
||||
$(XEN_LIBS) $(DRIVER_MODULE_LIBS) \
|
||||
@CYGWIN_EXTRA_LDFLAGS@ @MINGW_EXTRA_LDFLAGS@
|
||||
libvirt_la_CFLAGS = $(COVERAGE_CFLAGS) -DIN_LIBVIRT
|
||||
libvirt_la_DEPENDENCIES = $(libvirt_la_LIBADD) $(builddir)/libvirt_sym.version
|
||||
libvirt_la_DEPENDENCIES = $(libvirt_la_LIBADD) libvirt_sym.version
|
||||
|
||||
# Create an automake "convenience library" version of libvirt_la,
|
||||
# just for testing, since the test harness requires access to internal
|
||||
|
@ -1159,13 +1159,16 @@ static int
|
||||
xenUnifiedDomainGetAutostart (virDomainPtr dom, int *autostart)
|
||||
{
|
||||
GET_PRIVATE(dom->conn);
|
||||
int i;
|
||||
|
||||
for (i = 0; i < XEN_UNIFIED_NR_DRIVERS; ++i)
|
||||
if (priv->opened[i] && drivers[i]->domainGetAutostart &&
|
||||
drivers[i]->domainGetAutostart (dom, autostart) == 0)
|
||||
return 0;
|
||||
if (priv->xendConfigVersion < 3) {
|
||||
if (priv->opened[XEN_UNIFIED_XM_OFFSET])
|
||||
return xenXMDomainGetAutostart(dom, autostart);
|
||||
} else {
|
||||
if (priv->opened[XEN_UNIFIED_XEND_OFFSET])
|
||||
return xenDaemonDomainGetAutostart(dom, autostart);
|
||||
}
|
||||
|
||||
xenUnifiedError (dom->conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -1173,13 +1176,16 @@ static int
|
||||
xenUnifiedDomainSetAutostart (virDomainPtr dom, int autostart)
|
||||
{
|
||||
GET_PRIVATE(dom->conn);
|
||||
int i;
|
||||
|
||||
for (i = 0; i < XEN_UNIFIED_NR_DRIVERS; ++i)
|
||||
if (priv->opened[i] && drivers[i]->domainSetAutostart &&
|
||||
drivers[i]->domainSetAutostart (dom, autostart) == 0)
|
||||
return 0;
|
||||
if (priv->xendConfigVersion < 3) {
|
||||
if (priv->opened[XEN_UNIFIED_XM_OFFSET])
|
||||
return xenXMDomainSetAutostart(dom, autostart);
|
||||
} else {
|
||||
if (priv->opened[XEN_UNIFIED_XEND_OFFSET])
|
||||
return xenDaemonDomainSetAutostart(dom, autostart);
|
||||
}
|
||||
|
||||
xenUnifiedError (dom->conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -2669,3 +2669,84 @@ xenXMDomainBlockPeek (virDomainPtr dom,
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
static char *xenXMAutostartLinkName(virDomainPtr dom)
|
||||
{
|
||||
char *ret;
|
||||
if (asprintf(&ret, "/etc/xen/auto/%s", dom->name) < 0)
|
||||
return NULL;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static char *xenXMDomainConfigName(virDomainPtr dom)
|
||||
{
|
||||
char *ret;
|
||||
if (asprintf(&ret, "/etc/xen/%s", dom->name) < 0)
|
||||
return NULL;
|
||||
return ret;
|
||||
}
|
||||
|
||||
int xenXMDomainGetAutostart(virDomainPtr dom, int *autostart)
|
||||
{
|
||||
char *linkname = xenXMAutostartLinkName(dom);
|
||||
char *config = xenXMDomainConfigName(dom);
|
||||
int ret = -1;
|
||||
|
||||
if (!linkname || !config) {
|
||||
xenXMError(dom->conn, VIR_ERR_NO_MEMORY, NULL);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
*autostart = virFileLinkPointsTo(linkname, config);
|
||||
if (*autostart < 0) {
|
||||
xenXMError(dom->conn, VIR_ERR_INTERNAL_ERROR,
|
||||
_("failed to check autostart link %s: %s"),
|
||||
linkname, strerror(errno));
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
ret = 0;
|
||||
|
||||
cleanup:
|
||||
VIR_FREE(linkname);
|
||||
VIR_FREE(config);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
int xenXMDomainSetAutostart(virDomainPtr dom, int autostart)
|
||||
{
|
||||
char *linkname = xenXMAutostartLinkName(dom);
|
||||
char *config = xenXMDomainConfigName(dom);
|
||||
int ret = -1;
|
||||
|
||||
if (!linkname || !config) {
|
||||
xenXMError(dom->conn, VIR_ERR_NO_MEMORY, NULL);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (autostart) {
|
||||
if (symlink(config, linkname) < 0 &&
|
||||
errno != EEXIST) {
|
||||
xenXMError(dom->conn, VIR_ERR_INTERNAL_ERROR,
|
||||
"failed to create link %s: %s",
|
||||
linkname, strerror(errno));
|
||||
goto cleanup;
|
||||
}
|
||||
} else {
|
||||
if (unlink(linkname) < 0 &&
|
||||
errno != ENOENT) {
|
||||
xenXMError(dom->conn, VIR_ERR_INTERNAL_ERROR,
|
||||
"failed to remove link %s: %s",
|
||||
linkname, strerror(errno));
|
||||
goto cleanup;
|
||||
}
|
||||
}
|
||||
ret = 0;
|
||||
|
||||
cleanup:
|
||||
VIR_FREE(linkname);
|
||||
VIR_FREE(config);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -65,4 +65,7 @@ virDomainDefPtr xenXMDomainConfigParse(virConnectPtr conn, virConfPtr conf);
|
||||
|
||||
int xenXMDomainBlockPeek (virDomainPtr dom, const char *path, unsigned long long offset, size_t size, void *buffer);
|
||||
|
||||
int xenXMDomainGetAutostart(virDomainPtr dom, int *autostart);
|
||||
int xenXMDomainSetAutostart(virDomainPtr dom, int autostart);
|
||||
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user