mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 13:45:38 +00:00
Split all QEMU process mangement code into separate file
Move the qemudStartVMDaemon and qemudShutdownVMDaemon methods into a separate file, renaming them to qemuProcessStart, qemuProcessStop. All helper methods called by these are also moved & renamed to match * src/Makefile.am: Add qemu_process.c/.h * src/qemu/qemu_command.c: Add qemuDomainAssignPCIAddresses * src/qemu/qemu_command.h: Add VNC port min/max * src/qemu/qemu_domain.c, src/qemu/qemu_domain.h: Add domain event queue helpers * src/qemu/qemu_driver.c, src/qemu/qemu_driver.h: Remove all QEMU process startup/shutdown functions * src/qemu/qemu_process.c, src/qemu/qemu_process.h: Add all QEMU process startup/shutdown functions
This commit is contained in:
parent
df1011ca8e
commit
48c2d6c65b
@ -61,6 +61,7 @@ src/qemu/qemu_hotplug.c
|
||||
src/qemu/qemu_monitor.c
|
||||
src/qemu/qemu_monitor_json.c
|
||||
src/qemu/qemu_monitor_text.c
|
||||
src/qemu/qemu_process.c
|
||||
src/remote/remote_driver.c
|
||||
src/secret/secret_driver.c
|
||||
src/security/security_apparmor.c
|
||||
|
@ -281,6 +281,7 @@ 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_monitor.c qemu/qemu_monitor.h \
|
||||
qemu/qemu_monitor_text.c \
|
||||
qemu/qemu_monitor_text.h \
|
||||
|
@ -715,6 +715,35 @@ static int qemuCollectPCIAddress(virDomainDefPtr def ATTRIBUTE_UNUSED,
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
qemuDomainAssignPCIAddresses(virDomainDefPtr def)
|
||||
{
|
||||
int ret = -1;
|
||||
unsigned long long qemuCmdFlags = 0;
|
||||
qemuDomainPCIAddressSetPtr addrs = NULL;
|
||||
|
||||
if (qemuCapsExtractVersionInfo(def->emulator, def->os.arch,
|
||||
NULL,
|
||||
&qemuCmdFlags) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (qemuCmdFlags & QEMUD_CMD_FLAG_DEVICE) {
|
||||
if (!(addrs = qemuDomainPCIAddressSetCreate(def)))
|
||||
goto cleanup;
|
||||
|
||||
if (qemuAssignDevicePCISlots(def, addrs) < 0)
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
ret = 0;
|
||||
|
||||
cleanup:
|
||||
qemuDomainPCIAddressSetFree(addrs);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
qemuDomainPCIAddressSetPtr qemuDomainPCIAddressSetCreate(virDomainDefPtr def)
|
||||
{
|
||||
qemuDomainPCIAddressSetPtr addrs;
|
||||
|
@ -37,6 +37,10 @@
|
||||
# define QEMU_VIRTIO_SERIAL_PREFIX "virtio-serial"
|
||||
# define QEMU_FSDEV_HOST_PREFIX "fsdev-"
|
||||
|
||||
# define QEMU_VNC_PORT_MIN 5900
|
||||
# define QEMU_VNC_PORT_MAX 65535
|
||||
|
||||
|
||||
virCommandPtr qemuBuildCommandLine(virConnectPtr conn,
|
||||
struct qemud_driver *driver,
|
||||
virDomainDefPtr def,
|
||||
@ -134,6 +138,7 @@ virDomainDefPtr qemuParseCommandLine(virCapsPtr caps,
|
||||
virDomainDefPtr qemuParseCommandLineString(virCapsPtr caps,
|
||||
const char *args);
|
||||
|
||||
int qemuDomainAssignPCIAddresses(virDomainDefPtr def);
|
||||
qemuDomainPCIAddressSetPtr qemuDomainPCIAddressSetCreate(virDomainDefPtr def);
|
||||
int qemuDomainPCIAddressReserveSlot(qemuDomainPCIAddressSetPtr addrs,
|
||||
int slot);
|
||||
|
@ -29,6 +29,7 @@
|
||||
#include "logging.h"
|
||||
#include "virterror_internal.h"
|
||||
#include "c-ctype.h"
|
||||
#include "event.h"
|
||||
|
||||
#include <sys/time.h>
|
||||
|
||||
@ -41,6 +42,61 @@
|
||||
#define timeval_to_ms(tv) (((tv).tv_sec * 1000ull) + ((tv).tv_usec / 1000))
|
||||
|
||||
|
||||
static void qemuDomainEventDispatchFunc(virConnectPtr conn,
|
||||
virDomainEventPtr event,
|
||||
virConnectDomainEventGenericCallback cb,
|
||||
void *cbopaque,
|
||||
void *opaque)
|
||||
{
|
||||
struct qemud_driver *driver = opaque;
|
||||
|
||||
/* Drop the lock whle dispatching, for sake of re-entrancy */
|
||||
qemuDriverUnlock(driver);
|
||||
virDomainEventDispatchDefaultFunc(conn, event, cb, cbopaque, NULL);
|
||||
qemuDriverLock(driver);
|
||||
}
|
||||
|
||||
void qemuDomainEventFlush(int timer ATTRIBUTE_UNUSED, void *opaque)
|
||||
{
|
||||
struct qemud_driver *driver = opaque;
|
||||
virDomainEventQueue tempQueue;
|
||||
|
||||
qemuDriverLock(driver);
|
||||
|
||||
driver->domainEventDispatching = 1;
|
||||
|
||||
/* Copy the queue, so we're reentrant safe */
|
||||
tempQueue.count = driver->domainEventQueue->count;
|
||||
tempQueue.events = driver->domainEventQueue->events;
|
||||
driver->domainEventQueue->count = 0;
|
||||
driver->domainEventQueue->events = NULL;
|
||||
|
||||
virEventUpdateTimeout(driver->domainEventTimer, -1);
|
||||
virDomainEventQueueDispatch(&tempQueue,
|
||||
driver->domainEventCallbacks,
|
||||
qemuDomainEventDispatchFunc,
|
||||
driver);
|
||||
|
||||
/* Purge any deleted callbacks */
|
||||
virDomainEventCallbackListPurgeMarked(driver->domainEventCallbacks);
|
||||
|
||||
driver->domainEventDispatching = 0;
|
||||
qemuDriverUnlock(driver);
|
||||
}
|
||||
|
||||
|
||||
/* driver must be locked before calling */
|
||||
void qemuDomainEventQueue(struct qemud_driver *driver,
|
||||
virDomainEventPtr event)
|
||||
{
|
||||
if (virDomainEventQueuePush(driver->domainEventQueue,
|
||||
event) < 0)
|
||||
virDomainEventFree(event);
|
||||
if (driver->domainEventQueue->count == 1)
|
||||
virEventUpdateTimeout(driver->domainEventTimer, 0);
|
||||
}
|
||||
|
||||
|
||||
static void *qemuDomainObjPrivateAlloc(void)
|
||||
{
|
||||
qemuDomainObjPrivatePtr priv;
|
||||
|
@ -77,6 +77,17 @@ struct _qemuDomainObjPrivate {
|
||||
int persistentAddrs;
|
||||
};
|
||||
|
||||
struct qemuDomainWatchdogEvent
|
||||
{
|
||||
virDomainObjPtr vm;
|
||||
int action;
|
||||
};
|
||||
|
||||
void qemuDomainEventFlush(int timer ATTRIBUTE_UNUSED, void *opaque);
|
||||
|
||||
/* driver must be locked before calling */
|
||||
void qemuDomainEventQueue(struct qemud_driver *driver,
|
||||
virDomainEventPtr event);
|
||||
|
||||
void qemuDomainSetPrivateDataHooks(virCapsPtr caps);
|
||||
void qemuDomainSetNamespaceHooks(virCapsPtr caps);
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -21,34 +21,9 @@
|
||||
* Author: Daniel P. Berrange <berrange@redhat.com>
|
||||
*/
|
||||
|
||||
|
||||
#ifndef QEMUD_DRIVER_H
|
||||
# define QEMUD_DRIVER_H
|
||||
|
||||
# include <config.h>
|
||||
|
||||
# include <libxml/xpath.h>
|
||||
|
||||
# include "internal.h"
|
||||
|
||||
# if HAVE_LINUX_KVM_H
|
||||
# include <linux/kvm.h>
|
||||
# endif
|
||||
|
||||
/* device for kvm ioctls */
|
||||
# define KVM_DEVICE "/dev/kvm"
|
||||
|
||||
/* add definitions missing in older linux/kvm.h */
|
||||
# ifndef KVMIO
|
||||
# define KVMIO 0xAE
|
||||
# endif
|
||||
# ifndef KVM_CHECK_EXTENSION
|
||||
# define KVM_CHECK_EXTENSION _IO(KVMIO, 0x03)
|
||||
# endif
|
||||
# ifndef KVM_CAP_NR_VCPUS
|
||||
# define KVM_CAP_NR_VCPUS 9 /* returns max vcpus per vm */
|
||||
# endif
|
||||
#ifndef __QEMU_DRIVER_H__
|
||||
# define __QEMU_DRIVER_H__
|
||||
|
||||
int qemuRegister(void);
|
||||
|
||||
#endif /* QEMUD_DRIVER_H */
|
||||
#endif /* __QEMU_DRIVER_H__ */
|
||||
|
2418
src/qemu/qemu_process.c
Normal file
2418
src/qemu/qemu_process.c
Normal file
File diff suppressed because it is too large
Load Diff
52
src/qemu/qemu_process.h
Normal file
52
src/qemu/qemu_process.h
Normal file
@ -0,0 +1,52 @@
|
||||
/*
|
||||
* qemu_process.c: QEMU process management
|
||||
*
|
||||
* 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_PROCESS_H__
|
||||
# define __QEMU_PROCESS_H__
|
||||
|
||||
# include "qemu_conf.h"
|
||||
|
||||
int qemuProcessPrepareMonitorChr(struct qemud_driver *driver,
|
||||
virDomainChrSourceDefPtr monConfig,
|
||||
const char *vm);
|
||||
|
||||
int qemuProcessStartCPUs(struct qemud_driver *driver, virDomainObjPtr vm, virConnectPtr conn);
|
||||
int qemuProcessStopCPUs(struct qemud_driver *driver, virDomainObjPtr vm);
|
||||
|
||||
void qemuProcessAutostartAll(struct qemud_driver *driver);
|
||||
void qemuProcessReconnectAll(virConnectPtr conn, struct qemud_driver *driver);
|
||||
|
||||
int qemuProcessAssignPCIAddresses(virDomainDefPtr def);
|
||||
|
||||
int qemuProcessStart(virConnectPtr conn,
|
||||
struct qemud_driver *driver,
|
||||
virDomainObjPtr vm,
|
||||
const char *migrateFrom,
|
||||
bool start_paused,
|
||||
int stdin_fd,
|
||||
const char *stdin_path,
|
||||
enum virVMOperationType vmop);
|
||||
|
||||
void qemuProcessStop(struct qemud_driver *driver,
|
||||
virDomainObjPtr vm,
|
||||
int migrated);
|
||||
|
||||
#endif /* __QEMU_PROCESS_H__ */
|
Loading…
Reference in New Issue
Block a user