mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-08-26 18:41:17 +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>
|
Tue Nov 25 10:43:40 GMT 2008 Daniel P. Berrange <berrange@redhat.com>
|
||||||
|
|
||||||
Xen domain lifecycle events (Ben Guthro & Daniel Berrange)
|
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_CFLAGS = $(XEN_CFLAGS)
|
||||||
libvirt_driver_la_LDFLAGS = $(XEN_LIBS)
|
libvirt_driver_la_LDFLAGS = $(XEN_LIBS)
|
||||||
|
|
||||||
libvirt_driver_la_CFLAGS = $(XEN_CFLAGS)
|
|
||||||
|
|
||||||
if WITH_TEST
|
if WITH_TEST
|
||||||
if WITH_DRIVER_MODULES
|
if WITH_DRIVER_MODULES
|
||||||
mod_LTLIBRARIES += libvirt_driver_test.la
|
mod_LTLIBRARIES += libvirt_driver_test.la
|
||||||
@ -397,14 +395,14 @@ EXTRA_DIST += \
|
|||||||
libvirt_la_SOURCES =
|
libvirt_la_SOURCES =
|
||||||
libvirt_la_LIBADD += \
|
libvirt_la_LIBADD += \
|
||||||
@CYGWIN_EXTRA_LIBADD@ ../gnulib/lib/libgnu.la
|
@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@ \
|
-version-info @LIBVIRT_VERSION_INFO@ \
|
||||||
$(COVERAGE_CFLAGS:-f%=-Wc,-f%) \
|
$(COVERAGE_CFLAGS:-f%=-Wc,-f%) \
|
||||||
$(LIBXML_LIBS) $(SELINUX_LIBS) \
|
$(LIBXML_LIBS) $(SELINUX_LIBS) \
|
||||||
$(XEN_LIBS) $(DRIVER_MODULE_LIBS) \
|
$(XEN_LIBS) $(DRIVER_MODULE_LIBS) \
|
||||||
@CYGWIN_EXTRA_LDFLAGS@ @MINGW_EXTRA_LDFLAGS@
|
@CYGWIN_EXTRA_LDFLAGS@ @MINGW_EXTRA_LDFLAGS@
|
||||||
libvirt_la_CFLAGS = $(COVERAGE_CFLAGS) -DIN_LIBVIRT
|
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,
|
# Create an automake "convenience library" version of libvirt_la,
|
||||||
# just for testing, since the test harness requires access to internal
|
# just for testing, since the test harness requires access to internal
|
||||||
|
@ -1159,13 +1159,16 @@ static int
|
|||||||
xenUnifiedDomainGetAutostart (virDomainPtr dom, int *autostart)
|
xenUnifiedDomainGetAutostart (virDomainPtr dom, int *autostart)
|
||||||
{
|
{
|
||||||
GET_PRIVATE(dom->conn);
|
GET_PRIVATE(dom->conn);
|
||||||
int i;
|
|
||||||
|
|
||||||
for (i = 0; i < XEN_UNIFIED_NR_DRIVERS; ++i)
|
if (priv->xendConfigVersion < 3) {
|
||||||
if (priv->opened[i] && drivers[i]->domainGetAutostart &&
|
if (priv->opened[XEN_UNIFIED_XM_OFFSET])
|
||||||
drivers[i]->domainGetAutostart (dom, autostart) == 0)
|
return xenXMDomainGetAutostart(dom, autostart);
|
||||||
return 0;
|
} else {
|
||||||
|
if (priv->opened[XEN_UNIFIED_XEND_OFFSET])
|
||||||
|
return xenDaemonDomainGetAutostart(dom, autostart);
|
||||||
|
}
|
||||||
|
|
||||||
|
xenUnifiedError (dom->conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1173,13 +1176,16 @@ static int
|
|||||||
xenUnifiedDomainSetAutostart (virDomainPtr dom, int autostart)
|
xenUnifiedDomainSetAutostart (virDomainPtr dom, int autostart)
|
||||||
{
|
{
|
||||||
GET_PRIVATE(dom->conn);
|
GET_PRIVATE(dom->conn);
|
||||||
int i;
|
|
||||||
|
|
||||||
for (i = 0; i < XEN_UNIFIED_NR_DRIVERS; ++i)
|
if (priv->xendConfigVersion < 3) {
|
||||||
if (priv->opened[i] && drivers[i]->domainSetAutostart &&
|
if (priv->opened[XEN_UNIFIED_XM_OFFSET])
|
||||||
drivers[i]->domainSetAutostart (dom, autostart) == 0)
|
return xenXMDomainSetAutostart(dom, autostart);
|
||||||
return 0;
|
} else {
|
||||||
|
if (priv->opened[XEN_UNIFIED_XEND_OFFSET])
|
||||||
|
return xenDaemonDomainSetAutostart(dom, autostart);
|
||||||
|
}
|
||||||
|
|
||||||
|
xenUnifiedError (dom->conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2669,3 +2669,84 @@ xenXMDomainBlockPeek (virDomainPtr dom,
|
|||||||
return -1;
|
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 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
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user