static int qemuDomainObjStart(virConnectPtr conn,
struct qemud_driver *driver,
virDomainObjPtr vm,
- bool start_paused,
- bool autodestroy,
- bool bypass_cache);
+ unsigned int flags);
static int qemudDomainGetMaxVcpus(virDomainPtr dom);
};
static void
-qemuAutostartDomain(void *payload, const void *name ATTRIBUTE_UNUSED, void *opaque)
+qemuAutostartDomain(void *payload, const void *name ATTRIBUTE_UNUSED,
+ void *opaque)
{
virDomainObjPtr vm = payload;
struct qemuAutostartData *data = opaque;
virErrorPtr err;
+ int flags = 0;
+
+ if (data->driver->autoStartBypassCache)
+ flags |= VIR_DOMAIN_START_BYPASS_CACHE;
virDomainObjLock(vm);
virResetLastError();
} else {
if (vm->autostart &&
!virDomainObjIsActive(vm) &&
- qemuDomainObjStart(data->conn, data->driver, vm,
- false, false,
- data->driver->autoStartBypassCache) < 0) {
+ qemuDomainObjStart(data->conn, data->driver, vm, flags) < 0) {
err = virGetLastError();
VIR_ERROR(_("Failed to autostart VM '%s': %s"),
vm->def->name,
qemuDomainObjStart(virConnectPtr conn,
struct qemud_driver *driver,
virDomainObjPtr vm,
- bool start_paused,
- bool autodestroy,
- bool bypass_cache)
+ unsigned int flags)
{
int ret = -1;
char *managed_save;
+ bool start_paused = (flags & VIR_DOMAIN_START_PAUSED) != 0;
+ bool autodestroy = (flags & VIR_DOMAIN_START_AUTODESTROY) != 0;
+ bool bypass_cache = (flags & VIR_DOMAIN_START_BYPASS_CACHE) != 0;
+ bool force_boot = (flags & VIR_DOMAIN_START_FORCE_BOOT) != 0;
/*
* If there is a managed saved state restore it instead of starting
goto cleanup;
if (virFileExists(managed_save)) {
- ret = qemuDomainObjRestore(conn, driver, vm, managed_save,
- bypass_cache);
+ if (force_boot) {
+ if (unlink(managed_save) < 0) {
+ virReportSystemError(errno,
+ _("cannot remove managed save file %s"),
+ managed_save);
+ goto cleanup;
+ }
+ } else {
+ ret = qemuDomainObjRestore(conn, driver, vm, managed_save,
+ bypass_cache);
- if ((ret == 0) && (unlink(managed_save) < 0))
- VIR_WARN("Failed to remove the managed state %s", managed_save);
+ if ((ret == 0) && (unlink(managed_save) < 0))
+ VIR_WARN("Failed to remove the managed state %s", managed_save);
- goto cleanup;
+ goto cleanup;
+ }
}
ret = qemuProcessStart(conn, driver, vm, NULL, start_paused,
virCheckFlags(VIR_DOMAIN_START_PAUSED |
VIR_DOMAIN_START_AUTODESTROY |
- VIR_DOMAIN_START_BYPASS_CACHE, -1);
+ VIR_DOMAIN_START_BYPASS_CACHE |
+ VIR_DOMAIN_START_FORCE_BOOT, -1);
qemuDriverLock(driver);
vm = virDomainFindByUUID(&driver->domains, dom->uuid);
goto endjob;
}
- if (qemuDomainObjStart(dom->conn, driver, vm,
- (flags & VIR_DOMAIN_START_PAUSED) != 0,
- (flags & VIR_DOMAIN_START_AUTODESTROY) != 0,
- (flags & VIR_DOMAIN_START_BYPASS_CACHE) != 0) < 0)
+ if (qemuDomainObjStart(dom->conn, driver, vm, flags) < 0)
goto endjob;
ret = 0;
{"console", VSH_OT_BOOL, 0, N_("attach to console after creation")},
#endif
{"paused", VSH_OT_BOOL, 0, N_("leave the guest paused after creation")},
- {"autodestroy", VSH_OT_BOOL, 0, N_("automatically destroy the guest when virsh disconnects")},
+ {"autodestroy", VSH_OT_BOOL, 0,
+ N_("automatically destroy the guest when virsh disconnects")},
{"bypass-cache", VSH_OT_BOOL, 0,
N_("avoid file system cache when loading")},
+ {"force-boot", VSH_OT_BOOL, 0,
+ N_("force fresh boot by discarding any managed save")},
{NULL, 0, 0, NULL}
};
flags |= VIR_DOMAIN_START_AUTODESTROY;
if (vshCommandOptBool(cmd, "bypass-cache"))
flags |= VIR_DOMAIN_START_BYPASS_CACHE;
+ if (vshCommandOptBool(cmd, "force-boot"))
+ flags |= VIR_DOMAIN_START_FORCE_BOOT;
/* Prefer older API unless we have to pass a flag. */
if ((flags ? virDomainCreateWithFlags(dom, flags)
I<on_shutdown> parameter in the domain's XML definition.
=item B<start> I<domain-name> [I<--console>] [I<--paused>] [I<--autodestroy>]
-[I<--bypass-cache>]
+[I<--bypass-cache>] [I<--force-boot>]
Start a (previously defined) inactive domain, either from the last
B<managedsave> state, or via a fresh boot if no managedsave state is
destroyed when virsh closes its connection to libvirt, or otherwise
exits. If I<--bypass-cache> is specified, and managedsave state exists,
the restore will avoid the file system cache, although this may slow
-down the operation.
+down the operation. If I<--force-boot> is specified, then any
+managedsave state is discarded and a fresh boot occurs.
=item B<suspend> I<domain-id>