View | Details | Raw Unified | Return to bug 19172 | Differences between
and this patch

Collapse All | Expand All

(-)a/src/xen/xen_driver.c (-3 / +53 lines)
Lines 564-587 xenUnifiedListDomains (virConnectPtr conn, int *ids, int maxids) Link Here
564
    /* Try xenstore. */
564
    /* Try xenstore. */
565
    if (priv->opened[XEN_UNIFIED_XS_OFFSET]) {
565
    if (priv->opened[XEN_UNIFIED_XS_OFFSET]) {
566
        ret = xenStoreListDomains (conn, ids, maxids);
566
        ret = xenStoreListDomains (conn, ids, maxids);
567
        DEBUG("xenStoreListDomains: %d", ret);
567
        if (ret >= 0) return ret;
568
        if (ret >= 0) return ret;
568
    }
569
    }
569
570
570
    /* Try HV. */
571
    /* Try HV. */
571
    if (priv->opened[XEN_UNIFIED_HYPERVISOR_OFFSET]) {
572
    if (priv->opened[XEN_UNIFIED_HYPERVISOR_OFFSET]) {
572
        ret = xenHypervisorListDomains (conn, ids, maxids);
573
        ret = xenHypervisorListDomains (conn, ids, maxids);
574
        DEBUG("xenHypervisorListDomains: %d", ret);
573
        if (ret >= 0) return ret;
575
        if (ret >= 0) return ret;
574
    }
576
    }
575
577
576
    /* Try xend. */
578
    /* Try xend. */
577
    if (priv->opened[XEN_UNIFIED_XEND_OFFSET]) {
579
    if (priv->opened[XEN_UNIFIED_XEND_OFFSET]) {
578
        ret = xenDaemonListDomains (conn, ids, maxids);
580
        ret = xenDaemonListDomains (conn, ids, maxids);
581
        DEBUG("xenDaemonListDomains: %d", ret);
579
        if (ret >= 0) return ret;
582
        if (ret >= 0) return ret;
580
    }
583
    }
581
584
582
    /* Try proxy. */
585
    /* Try proxy. */
583
    if (priv->opened[XEN_UNIFIED_PROXY_OFFSET]) {
586
    if (priv->opened[XEN_UNIFIED_PROXY_OFFSET]) {
584
        ret = xenProxyListDomains (conn, ids, maxids);
587
        ret = xenProxyListDomains (conn, ids, maxids);
588
        DEBUG("xenProxyListDomains: %d", ret);
585
        if (ret >= 0) return ret;
589
        if (ret >= 0) return ret;
586
    }
590
    }
587
    return -1;
591
    return -1;
Lines 1979-1984 out: Link Here
1979
    return ret;
1983
    return ret;
1980
}
1984
}
1981
1985
1986
static int
1987
xenUnifiedDomainManagedSave(virDomainPtr dom, unsigned int flags)
1988
{
1989
    GET_PRIVATE(dom->conn);
1990
    int i;
1991
1992
    for (i = 0; i < XEN_UNIFIED_NR_DRIVERS; ++i)
1993
        if (priv->opened[i] &&
1994
            drivers[i]->domainManagedSave &&
1995
            drivers[i]->domainManagedSave(dom, flags) == 0)
1996
            return 0;
1997
1998
    return -1;
1999
}
2000
2001
static int
2002
xenUnifiedDomainHasManagedSaveImage(virDomainPtr dom, unsigned int flags)
2003
{
2004
    GET_PRIVATE(dom->conn);
2005
    int i;
2006
2007
    for (i = 0; i < XEN_UNIFIED_NR_DRIVERS; ++i)
2008
        if (priv->opened[i] &&
2009
            drivers[i]->domainHasManagedSaveImage &&
2010
            drivers[i]->domainHasManagedSaveImage(dom, flags) == 0)
2011
            return 0;
2012
2013
    return -1;
2014
}
2015
2016
static int
2017
xenUnifiedDomainManagedSaveRemove(virDomainPtr dom, unsigned int flags)
2018
{
2019
    GET_PRIVATE(dom->conn);
2020
    int i;
2021
2022
    for (i = 0; i < XEN_UNIFIED_NR_DRIVERS; ++i)
2023
        if (priv->opened[i] &&
2024
            drivers[i]->domainManagedSaveRemove &&
2025
            drivers[i]->domainManagedSaveRemove(dom, flags) == 0)
2026
            return 0;
2027
2028
    return -1;
2029
}
2030
2031
1982
2032
1983
/*----- Register with libvirt.c, and initialize Xen drivers. -----*/
2033
/*----- Register with libvirt.c, and initialize Xen drivers. -----*/
1984
2034
Lines 2072-2080 static virDriver xenUnifiedDriver = { Link Here
2072
    NULL, /* domainMigrateSetMaxDowntime */
2122
    NULL, /* domainMigrateSetMaxDowntime */
2073
    xenUnifiedDomainEventRegisterAny, /* domainEventRegisterAny */
2123
    xenUnifiedDomainEventRegisterAny, /* domainEventRegisterAny */
2074
    xenUnifiedDomainEventDeregisterAny, /* domainEventDeregisterAny */
2124
    xenUnifiedDomainEventDeregisterAny, /* domainEventDeregisterAny */
2075
    NULL, /* domainManagedSave */
2125
    xenUnifiedDomainManagedSave, /* domainManagedSave */
2076
    NULL, /* domainHasManagedSaveImage */
2126
    xenUnifiedDomainHasManagedSaveImage, /* domainHasManagedSaveImage */
2077
    NULL, /* domainManagedSaveRemove */
2127
    xenUnifiedDomainManagedSaveRemove, /* domainManagedSaveRemove */
2078
    NULL, /* domainSnapshotCreateXML */
2128
    NULL, /* domainSnapshotCreateXML */
2079
    NULL, /* domainSnapshotDumpXML */
2129
    NULL, /* domainSnapshotDumpXML */
2080
    NULL, /* domainSnapshotNum */
2130
    NULL, /* domainSnapshotNum */
(-)a/src/xen/xen_driver.h (+3 lines)
Lines 99-104 struct xenUnifiedDriver { Link Here
99
        virDrvDomainGetSchedulerType	domainGetSchedulerType;
99
        virDrvDomainGetSchedulerType	domainGetSchedulerType;
100
        virDrvDomainGetSchedulerParameters domainGetSchedulerParameters;
100
        virDrvDomainGetSchedulerParameters domainGetSchedulerParameters;
101
        virDrvDomainSetSchedulerParameters domainSetSchedulerParameters;
101
        virDrvDomainSetSchedulerParameters domainSetSchedulerParameters;
102
        virDrvDomainManagedSave	domainManagedSave;
103
        virDrvDomainHasManagedSaveImage	domainHasManagedSaveImage;
104
        virDrvDomainManagedSaveRemove	domainManagedSaveRemove;
102
};
105
};
103
106
104
typedef struct xenXMConfCache *xenXMConfCachePtr;
107
typedef struct xenXMConfCache *xenXMConfCachePtr;
(-)a/src/xen/xend_internal.c (-2 / +191 lines)
Lines 952-958 xenDaemonListDomainsOld(virConnectPtr xend) Link Here
952
 * @xend: A xend instance
952
 * @xend: A xend instance
953
 * @sexpr: An S-Expr description of the domain.
953
 * @sexpr: An S-Expr description of the domain.
954
 *
954
 *
955
 * This method will create a domain based the passed in description.  The
955
 * This method will create a domain based on the passed in description.  The
956
 * domain will be paused after creation and must be unpaused with
956
 * domain will be paused after creation and must be unpaused with
957
 * xenDaemonResumeDomain() to begin execution.
957
 * xenDaemonResumeDomain() to begin execution.
958
 * This method may be deprecated once switching to XML-RPC based communcations
958
 * This method may be deprecated once switching to XML-RPC based communcations
Lines 2680-2685 error: Link Here
2680
}
2680
}
2681
#endif /* !PROXY */
2681
#endif /* !PROXY */
2682
2682
2683
static char *
2684
xenDaemonDomainManagedSavePath(virDomainPtr dom) {
2685
    char *ret;
2686
    char uuidstr[VIR_UUID_STRING_BUFLEN];
2687
2688
    virUUIDFormat(dom->uuid, uuidstr);
2689
    if (virAsprintf(&ret, "%s/%s/checkpoint.chk", XEND_DOMAINS_DIR, uuidstr) < 0) {
2690
        virReportOOMError();
2691
        return(NULL);
2692
    }
2693
2694
    return(ret);
2695
}
2696
2683
/*****************************************************************
2697
/*****************************************************************
2684
 ******
2698
 ******
2685
 ******
2699
 ******
Lines 4656-4663 virDomainPtr xenDaemonDomainDefineXML(virConnectPtr conn, const char *xmlDesc) { Link Here
4656
    virDomainDefFree(def);
4670
    virDomainDefFree(def);
4657
    return (NULL);
4671
    return (NULL);
4658
}
4672
}
4673
4659
int xenDaemonDomainCreate(virDomainPtr domain)
4674
int xenDaemonDomainCreate(virDomainPtr domain)
4660
{
4675
{
4676
    char *managed_save;
4661
    xenUnifiedPrivatePtr priv;
4677
    xenUnifiedPrivatePtr priv;
4662
    int ret;
4678
    int ret;
4663
    virDomainPtr tmp;
4679
    virDomainPtr tmp;
Lines 4672-4677 int xenDaemonDomainCreate(virDomainPtr domain) Link Here
4672
    if (priv->xendConfigVersion < 3)
4688
    if (priv->xendConfigVersion < 3)
4673
        return(-1);
4689
        return(-1);
4674
4690
4691
    /*
4692
     * If there is a managed saved state restore it instead of starting
4693
     * from scratch. In any case the old state is removed.
4694
     */
4695
    managed_save = xenDaemonDomainManagedSavePath(domain);
4696
    if ((managed_save) && (virFileExists(managed_save))) {
4697
        ret = xend_op(domain->conn, domain->name, "op", "resume", NULL);
4698
4699
        if (unlink(managed_save) < 0) {
4700
            VIR_WARN("Failed to remove the managed state %s", managed_save);
4701
        }
4702
4703
        if (ret == 0)
4704
            goto cleanup;
4705
    }
4706
4675
    ret = xend_op(domain->conn, domain->name, "op", "start", NULL);
4707
    ret = xend_op(domain->conn, domain->name, "op", "start", NULL);
4676
4708
4677
    if (ret != -1) {
4709
    if (ret != -1) {
Lines 4682-4687 int xenDaemonDomainCreate(virDomainPtr domain) Link Here
4682
            virDomainFree(tmp);
4714
            virDomainFree(tmp);
4683
        }
4715
        }
4684
    }
4716
    }
4717
4718
cleanup:
4719
    VIR_FREE(managed_save);
4685
    return ret;
4720
    return ret;
4686
}
4721
}
4687
4722
Lines 4737-4742 xenDaemonNumOfDefinedDomains(virConnectPtr conn) Link Here
4737
        ret++;
4772
        ret++;
4738
    }
4773
    }
4739
4774
4775
    sexpr_free(root);
4776
4777
    root = sexpr_get(conn, "/xend/domain?state=suspended");
4778
    if (root == NULL)
4779
        goto error;
4780
4781
    for (_for_i = root, node = root->u.s.car; _for_i->kind == SEXPR_CONS;
4782
         _for_i = _for_i->u.s.cdr, node = _for_i->u.s.car) {
4783
        if (node->kind != SEXPR_VALUE)
4784
            continue;
4785
        ret++;
4786
    }
4787
4740
error:
4788
error:
4741
    sexpr_free(root);
4789
    sexpr_free(root);
4742
    return(ret);
4790
    return(ret);
Lines 4777-4782 xenDaemonListDefinedDomains(virConnectPtr conn, char **const names, int maxnames Link Here
4777
            break;
4825
            break;
4778
    }
4826
    }
4779
4827
4828
    sexpr_free(root);
4829
4830
    root = sexpr_get(conn, "/xend/domain?state=suspended");
4831
    if (root == NULL)
4832
        goto error;
4833
4834
    for (_for_i = root, node = root->u.s.car; _for_i->kind == SEXPR_CONS;
4835
         _for_i = _for_i->u.s.cdr, node = _for_i->u.s.car) {
4836
        if (node->kind != SEXPR_VALUE)
4837
            continue;
4838
4839
        if ((names[ret++] = strdup(node->u.value)) == NULL) {
4840
            virReportOOMError();
4841
            goto error;
4842
        }
4843
4844
        if (ret >= maxnames)
4845
            break;
4846
    }
4847
4780
cleanup:
4848
cleanup:
4781
    sexpr_free(root);
4849
    sexpr_free(root);
4782
    return(ret);
4850
    return(ret);
Lines 5071-5077 error: Link Here
5071
5139
5072
/**
5140
/**
5073
 * xenDaemonDomainBlockPeek:
5141
 * xenDaemonDomainBlockPeek:
5074
 * @dom: domain object
5142
 * @domain: domain object
5075
 * @path: path to the file or device
5143
 * @path: path to the file or device
5076
 * @offset: offset
5144
 * @offset: offset
5077
 * @size: size
5145
 * @size: size
Lines 5159-5164 xenDaemonDomainBlockPeek (virDomainPtr domain, const char *path, Link Here
5159
    return ret;
5227
    return ret;
5160
}
5228
}
5161
5229
5230
/**
5231
 * xenDaemonDomainManagedSave:
5232
 * @domain: pointer to the domain
5233
 * @flags: optional flags currently unused
5234
 *
5235
 * This method will suspend a domain and save its memory contents to
5236
 * a file on disk. After the call, if successful, the domain is not
5237
 * listed as running anymore.
5238
 * The difference from virDomainSave() is that libvirt is keeping track of
5239
 * the saved state itself, and will reuse it once the domain is being
5240
 * restarted (automatically or via an explicit libvirt call).
5241
 * As a result any running domain is sure to not have a managed saved image.
5242
 *
5243
 * Returns 0 in case of success or -1 in case of failure
5244
 */
5245
int
5246
xenDaemonDomainManagedSave(virDomainPtr domain, unsigned int flags)
5247
{
5248
    if ((domain == NULL) || (domain->conn == NULL) || (domain->name == NULL)) {
5249
        virXendError(VIR_ERR_INVALID_ARG, __FUNCTION__);
5250
        return(-1);
5251
    }
5252
5253
    if (domain->id < 0) {
5254
        virXendError(VIR_ERR_OPERATION_INVALID,
5255
                     _("Domain %s isn't running."), domain->name);
5256
        return(-1);
5257
    }
5258
5259
    /* We can't save the state of Domain-0, that would mean stopping it too */
5260
    if (domain->id == 0) {
5261
        return(-1);
5262
    }
5263
5264
    virCheckFlags(0, -1);
5265
5266
    return xend_op(domain->conn, domain->name, "op", "suspend", NULL);
5267
}
5268
5269
/**
5270
 * xenDaemonDomainHasManagedSaveImage:
5271
 * @domain: pointer to the domain
5272
 * @flags: optional flags currently unused
5273
 *
5274
 * Check if a domain has a managed save image as created by
5275
 * virDomainManagedSave(). Note that any running domain should not have
5276
 * such an image, as it should have been removed on restart.
5277
 *
5278
 * Returns 0 if no image is present, 1 if an image is present, and
5279
 *         -1 in case of error
5280
 */
5281
int
5282
xenDaemonDomainHasManagedSaveImage(virDomainPtr domain, unsigned int flags)
5283
{
5284
    char *name = NULL;
5285
    int ret = -1;
5286
5287
    if ((domain == NULL) || (domain->conn == NULL) || (domain->name == NULL)) {
5288
        virXendError(VIR_ERR_INVALID_ARG, __FUNCTION__);
5289
        return(-1);
5290
    }
5291
5292
    /* We can't save the state of Domain-0, that would mean stopping it too */
5293
    if (domain->id == 0) {
5294
        return(-1);
5295
    }
5296
5297
    virCheckFlags(0, -1);
5298
5299
    name = xenDaemonDomainManagedSavePath(domain);
5300
    if (name == NULL)
5301
        goto cleanup;
5302
5303
    ret = virFileExists(name);
5304
5305
cleanup:
5306
    VIR_FREE(name);
5307
    return ret;
5308
}
5309
5310
/**
5311
 * xenDaemonDomainManagedSaveRemove:
5312
 * @domain: pointer to the domain
5313
 * @flags: optional flags currently unused
5314
 *
5315
 * Remove any managed save image for this domain.
5316
 *
5317
 * Returns 0 in case of success, and -1 in case of error
5318
 */
5319
int
5320
xenDaemonDomainManagedSaveRemove(virDomainPtr domain, unsigned int flags)
5321
{
5322
    char *name = NULL;
5323
    int ret = -1;
5324
5325
    if ((domain == NULL) || (domain->conn == NULL) || (domain->name == NULL)) {
5326
        virXendError(VIR_ERR_INVALID_ARG, __FUNCTION__);
5327
        return(-1);
5328
    }
5329
5330
    /* We can't save the state of Domain-0, that would mean stopping it too */
5331
    if (domain->id == 0) {
5332
        return(-1);
5333
    }
5334
5335
    virCheckFlags(0, -1);
5336
5337
    name = xenDaemonDomainManagedSavePath(domain);
5338
    if (name == NULL)
5339
        goto cleanup;
5340
5341
    ret = unlink(name);
5342
5343
cleanup:
5344
    VIR_FREE(name);
5345
    return ret;
5346
}
5347
5162
struct xenUnifiedDriver xenDaemonDriver = {
5348
struct xenUnifiedDriver xenDaemonDriver = {
5163
    xenDaemonOpen,               /* open */
5349
    xenDaemonOpen,               /* open */
5164
    xenDaemonClose,              /* close */
5350
    xenDaemonClose,              /* close */
Lines 5197-5202 struct xenUnifiedDriver xenDaemonDriver = { Link Here
5197
    xenDaemonGetSchedulerType,   /* domainGetSchedulerType */
5383
    xenDaemonGetSchedulerType,   /* domainGetSchedulerType */
5198
    xenDaemonGetSchedulerParameters, /* domainGetSchedulerParameters */
5384
    xenDaemonGetSchedulerParameters, /* domainGetSchedulerParameters */
5199
    xenDaemonSetSchedulerParameters, /* domainSetSchedulerParameters */
5385
    xenDaemonSetSchedulerParameters, /* domainSetSchedulerParameters */
5386
    xenDaemonDomainManagedSave,  /* domainManagedSave */
5387
    xenDaemonDomainHasManagedSaveImage,  /* domainHasManagedSaveImage */
5388
    xenDaemonDomainManagedSaveRemove,    /* domainManagedSaveRemove */
5200
};
5389
};
5201
5390
5202
/************************************************************************
5391
/************************************************************************
(-)a/src/xen/xend_internal.h (+3 lines)
Lines 144-149 int xenDaemonDomainGetInfo(virDomainPtr domain, virDomainInfoPtr info); Link Here
144
char *xenDaemonDomainDumpXML(virDomainPtr domain, int flags, const char *cpus);
144
char *xenDaemonDomainDumpXML(virDomainPtr domain, int flags, const char *cpus);
145
unsigned long xenDaemonDomainGetMaxMemory(virDomainPtr domain);
145
unsigned long xenDaemonDomainGetMaxMemory(virDomainPtr domain);
146
char **xenDaemonListDomainsOld(virConnectPtr xend);
146
char **xenDaemonListDomainsOld(virConnectPtr xend);
147
int xenDaemonDomainManagedSave(virDomainPtr dom, unsigned int flags);
148
int xenDaemonDomainHasManagedSaveImage(virDomainPtr dom, unsigned int flags);
149
int xenDaemonDomainManagedSaveRemove(virDomainPtr dom, unsigned int flags);
147
150
148
virDomainPtr xenDaemonDomainDefineXML(virConnectPtr xend, const char *sexpr);
151
virDomainPtr xenDaemonDomainDefineXML(virConnectPtr xend, const char *sexpr);
149
int xenDaemonDomainCreate(virDomainPtr domain);
152
int xenDaemonDomainCreate(virDomainPtr domain);
(-)a/tools/Makefile.am (+2 lines)
Lines 38-43 virt-pki-validate.1: virt-pki-validate Link Here
38
38
39
virsh_SOURCES =							\
39
virsh_SOURCES =							\
40
		console.c console.h				\
40
		console.c console.h				\
41
		@top_srcdir@/daemon/event.c			\
41
		virsh.c
42
		virsh.c
42
43
43
virsh_LDFLAGS = $(WARN_LDFLAGS) $(COVERAGE_LDFLAGS)
44
virsh_LDFLAGS = $(WARN_LDFLAGS) $(COVERAGE_LDFLAGS)
Lines 52-57 virsh_CFLAGS = \ Link Here
52
		-I../include -I$(top_srcdir)/include		\
53
		-I../include -I$(top_srcdir)/include		\
53
		-I$(top_srcdir)/src				\
54
		-I$(top_srcdir)/src				\
54
		-I$(top_srcdir)/src/util			\
55
		-I$(top_srcdir)/src/util			\
56
		-I$(top_srcdir)					\
55
		-DGETTEXT_PACKAGE=\"$(PACKAGE)\"		\
57
		-DGETTEXT_PACKAGE=\"$(PACKAGE)\"		\
56
		-DLOCALEBASEDIR=\""$(datadir)/locale"\"		\
58
		-DLOCALEBASEDIR=\""$(datadir)/locale"\"		\
57
		$(WARN_CFLAGS)					\
59
		$(WARN_CFLAGS)					\
(-)a/tools/virsh.c (+8 lines)
Lines 50-55 Link Here
50
#include "util.h"
50
#include "util.h"
51
#include "memory.h"
51
#include "memory.h"
52
#include "xml.h"
52
#include "xml.h"
53
#include "daemon/event.h"
53
54
54
static char *progname;
55
static char *progname;
55
56
Lines 11068-11073 vshInit(vshControl *ctl) Link Here
11068
    /* set up the signals handlers to catch disconnections */
11069
    /* set up the signals handlers to catch disconnections */
11069
    vshSetupSignals();
11070
    vshSetupSignals();
11070
11071
11072
    virEventRegisterImpl(virEventAddHandleImpl,
11073
                         virEventUpdateHandleImpl,
11074
                         virEventRemoveHandleImpl,
11075
                         virEventAddTimeoutImpl,
11076
                         virEventUpdateTimeoutImpl,
11077
                         virEventRemoveTimeoutImpl);
11078
11071
    ctl->conn = virConnectOpenAuth(ctl->name,
11079
    ctl->conn = virConnectOpenAuth(ctl->name,
11072
                                   virConnectAuthPtrDefault,
11080
                                   virConnectAuthPtrDefault,
11073
                                   ctl->readonly ? VIR_CONNECT_RO : 0);
11081
                                   ctl->readonly ? VIR_CONNECT_RO : 0);

Return to bug 19172