|
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 |
/************************************************************************ |