mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-21 20:15:17 +00:00
Move all the QEMU migration code to a new file
The introduction of the v3 migration protocol, along with support for migration cookies, will significantly expand the size of the migration code. Move it all to a separate file to make it more manageable The functions are not moved 100%. The API entry points remain in the main QEMU driver, but once the public virDomainPtr is resolved to the internal virDomainObjPtr, all following code is moved. This will allow the new v3 API entry points to call into the same shared internal migration functions * src/qemu/qemu_domain.c, src/qemu/qemu_domain.h: Add qemuDomainFormatXML helper method * src/qemu/qemu_driver.c: Remove all migration code * src/qemu/qemu_migration.c, src/qemu/qemu_migration.h: Add all migration code.
This commit is contained in:
parent
48c2d6c65b
commit
766de43533
@ -58,6 +58,7 @@ src/qemu/qemu_domain.c
|
||||
src/qemu/qemu_driver.c
|
||||
src/qemu/qemu_hostdev.c
|
||||
src/qemu/qemu_hotplug.c
|
||||
src/qemu/qemu_migration.c
|
||||
src/qemu/qemu_monitor.c
|
||||
src/qemu/qemu_monitor_json.c
|
||||
src/qemu/qemu_monitor_text.c
|
||||
|
@ -281,7 +281,8 @@ QEMU_DRIVER_SOURCES = \
|
||||
qemu/qemu_hostdev.c qemu/qemu_hostdev.h \
|
||||
qemu/qemu_hotplug.c qemu/qemu_hotplug.h \
|
||||
qemu/qemu_conf.c qemu/qemu_conf.h \
|
||||
qemu/qemu_process.c qemu/qemu_process.h \
|
||||
qemu/qemu_process.c qemu/qemu_process.h \
|
||||
qemu/qemu_migration.c qemu/qemu_migration.h \
|
||||
qemu/qemu_monitor.c qemu/qemu_monitor.h \
|
||||
qemu/qemu_monitor_text.c \
|
||||
qemu/qemu_monitor_text.h \
|
||||
|
@ -30,6 +30,7 @@
|
||||
#include "virterror_internal.h"
|
||||
#include "c-ctype.h"
|
||||
#include "event.h"
|
||||
#include "cpu/cpu.h"
|
||||
|
||||
#include <sys/time.h>
|
||||
|
||||
@ -653,3 +654,41 @@ void qemuDomainObjExitRemoteWithDriver(struct qemud_driver *driver,
|
||||
virDomainObjLock(obj);
|
||||
virDomainObjUnref(obj);
|
||||
}
|
||||
|
||||
|
||||
char *qemuDomainFormatXML(struct qemud_driver *driver,
|
||||
virDomainObjPtr vm,
|
||||
int flags)
|
||||
{
|
||||
char *ret = NULL;
|
||||
virCPUDefPtr cpu = NULL;
|
||||
virDomainDefPtr def;
|
||||
virCPUDefPtr def_cpu;
|
||||
|
||||
if ((flags & VIR_DOMAIN_XML_INACTIVE) && vm->newDef)
|
||||
def = vm->newDef;
|
||||
else
|
||||
def = vm->def;
|
||||
def_cpu = def->cpu;
|
||||
|
||||
/* Update guest CPU requirements according to host CPU */
|
||||
if ((flags & VIR_DOMAIN_XML_UPDATE_CPU) && def_cpu && def_cpu->model) {
|
||||
if (!driver->caps || !driver->caps->host.cpu) {
|
||||
qemuReportError(VIR_ERR_OPERATION_FAILED,
|
||||
"%s", _("cannot get host CPU capabilities"));
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (!(cpu = virCPUDefCopy(def_cpu))
|
||||
|| cpuUpdate(cpu, driver->caps->host.cpu))
|
||||
goto cleanup;
|
||||
def->cpu = cpu;
|
||||
}
|
||||
|
||||
ret = virDomainDefFormat(def, flags);
|
||||
|
||||
cleanup:
|
||||
def->cpu = def_cpu;
|
||||
virCPUDefFree(cpu);
|
||||
return ret;
|
||||
}
|
||||
|
@ -107,4 +107,8 @@ void qemuDomainObjEnterRemoteWithDriver(struct qemud_driver *driver,
|
||||
void qemuDomainObjExitRemoteWithDriver(struct qemud_driver *driver,
|
||||
virDomainObjPtr obj);
|
||||
|
||||
char *qemuDomainFormatXML(struct qemud_driver *driver,
|
||||
virDomainObjPtr vm,
|
||||
int flags);
|
||||
|
||||
#endif /* __QEMU_DOMAIN_H__ */
|
||||
|
File diff suppressed because it is too large
Load Diff
1291
src/qemu/qemu_migration.c
Normal file
1291
src/qemu/qemu_migration.c
Normal file
File diff suppressed because it is too large
Load Diff
63
src/qemu/qemu_migration.h
Normal file
63
src/qemu/qemu_migration.h
Normal file
@ -0,0 +1,63 @@
|
||||
/*
|
||||
* qemu_migration.h: QEMU migration handling
|
||||
*
|
||||
* Copyright (C) 2006-2011 Red Hat, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __QEMU_MIGRATION_H__
|
||||
# define __QEMU_MIGRATION_H__
|
||||
|
||||
# include "qemu_conf.h"
|
||||
|
||||
|
||||
bool qemuMigrationIsAllowed(virDomainDefPtr def)
|
||||
ATTRIBUTE_NONNULL(1);
|
||||
int qemuMigrationSetOffline(struct qemud_driver *driver,
|
||||
virDomainObjPtr vm);
|
||||
|
||||
int qemuMigrationWaitForCompletion(struct qemud_driver *driver, virDomainObjPtr vm);
|
||||
|
||||
int qemuMigrationPrepareTunnel(struct qemud_driver *driver,
|
||||
virConnectPtr dconn,
|
||||
virStreamPtr st,
|
||||
const char *dname,
|
||||
const char *dom_xml);
|
||||
|
||||
int qemuMigrationPrepareDirect(struct qemud_driver *driver,
|
||||
virConnectPtr dconn,
|
||||
const char *uri_in,
|
||||
char **uri_out,
|
||||
const char *dname,
|
||||
const char *dom_xml);
|
||||
|
||||
int qemuMigrationPerform(struct qemud_driver *driver,
|
||||
virConnectPtr conn,
|
||||
virDomainObjPtr vm,
|
||||
const char *uri,
|
||||
unsigned long flags,
|
||||
const char *dname,
|
||||
unsigned long resource);
|
||||
|
||||
virDomainPtr qemuMigrationFinish(struct qemud_driver *driver,
|
||||
virConnectPtr dconn,
|
||||
virDomainObjPtr vm,
|
||||
unsigned long flags,
|
||||
int retcode);
|
||||
|
||||
|
||||
#endif /* __QEMU_MIGRATION_H__ */
|
Loading…
x
Reference in New Issue
Block a user