qemu: Move PostParse functions out of qemu_domain.c

Problem with qemu_domain.c is that it's constantly growing. But
there are few options for improvement. For instance, validation
functions were moved out and now live in qemu_validate.c. We can
do the same for PostParse functions, though since PostParse may
modify domain definition, some functions need to be exported from
qemu_domain.c.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
This commit is contained in:
Michal Privoznik 2024-11-12 15:55:14 +01:00
parent bf2af76ec2
commit 24580d13d1
7 changed files with 2001 additions and 1895 deletions

View File

@ -189,6 +189,7 @@ src/qemu/qemu_monitor_text.c
src/qemu/qemu_namespace.c src/qemu/qemu_namespace.c
src/qemu/qemu_nbdkit.c src/qemu/qemu_nbdkit.c
src/qemu/qemu_passt.c src/qemu/qemu_passt.c
src/qemu/qemu_postparse.c
src/qemu/qemu_process.c src/qemu/qemu_process.c
src/qemu/qemu_qapi.c src/qemu/qemu_qapi.c
src/qemu/qemu_saveimage.c src/qemu/qemu_saveimage.c

View File

@ -32,6 +32,7 @@ qemu_driver_sources = [
'qemu_namespace.c', 'qemu_namespace.c',
'qemu_nbdkit.c', 'qemu_nbdkit.c',
'qemu_passt.c', 'qemu_passt.c',
'qemu_postparse.c',
'qemu_process.c', 'qemu_process.c',
'qemu_qapi.c', 'qemu_qapi.c',
'qemu_saveimage.c', 'qemu_saveimage.c',

File diff suppressed because it is too large Load Diff

View File

@ -780,6 +780,9 @@ void qemuDomainCleanupRun(virQEMUDriver *driver,
void qemuDomainObjPrivateDataClear(qemuDomainObjPrivate *priv); void qemuDomainObjPrivateDataClear(qemuDomainObjPrivate *priv);
int qemuStorageSourcePrivateDataAssignSecinfo(qemuDomainSecretInfo **secinfo,
char **alias);
extern virDomainXMLPrivateDataCallbacks virQEMUDriverPrivateDataCallbacks; extern virDomainXMLPrivateDataCallbacks virQEMUDriverPrivateDataCallbacks;
extern virXMLNamespace virQEMUDriverDomainXMLNamespace; extern virXMLNamespace virQEMUDriverDomainXMLNamespace;
extern virDomainDefParserConfig virQEMUDriverDomainDefParserConfig; extern virDomainDefParserConfig virQEMUDriverDomainDefParserConfig;
@ -849,6 +852,11 @@ int qemuDomainGetSCSIControllerModel(const virDomainDef *def,
const virDomainControllerDef *cont, const virDomainControllerDef *cont,
virQEMUCaps *qemuCaps); virQEMUCaps *qemuCaps);
int qemuDomainDefAddDefaultAudioBackend(virQEMUDriver *driver,
virDomainDef *def);
virDomainPanicModel qemuDomainDefaultPanicModel(const virDomainDef *def);
void qemuDomainUpdateCurrentMemorySize(virDomainObj *vm); void qemuDomainUpdateCurrentMemorySize(virDomainObj *vm);
unsigned long long qemuDomainGetMemLockLimitBytes(virDomainDef *def); unsigned long long qemuDomainGetMemLockLimitBytes(virDomainDef *def);
@ -938,8 +946,12 @@ int qemuDomainSecretPrepare(virQEMUDriver *driver,
virDomainObj *vm) virDomainObj *vm)
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
int qemuDomainDeviceDiskDefPostParse(virDomainDiskDef *disk, void
unsigned int parseFlags); qemuDomainChrDefDropDefaultPath(virDomainChrDef *chr,
virQEMUDriver *driver);
int
qemuDomainNVDimmAlignSizePseries(virDomainMemoryDef *mem);
int qemuDomainPrepareChannel(virDomainChrDef *chr, int qemuDomainPrepareChannel(virDomainChrDef *chr,
const char *domainChannelTargetDir) const char *domainChannelTargetDir)

1925
src/qemu/qemu_postparse.c Normal file

File diff suppressed because it is too large Load Diff

54
src/qemu/qemu_postparse.h Normal file
View File

@ -0,0 +1,54 @@
/*
* qemu_postparse.h: QEMU domain PostParse functions
*
* Copyright (C) 2006-2024 Red Hat, Inc.
* Copyright (C) 2006 Daniel P. Berrange
*
* 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, see
* <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "virconftypes.h"
int
qemuDomainDeviceDiskDefPostParse(virDomainDiskDef *disk,
unsigned int parseFlags);
int
qemuDomainDeviceDefPostParse(virDomainDeviceDef *dev,
const virDomainDef *def,
unsigned int parseFlags,
void *opaque,
void *parseOpaque);
int
qemuDomainDefPostParseBasic(virDomainDef *def,
void *opaque);
int
qemuDomainDefPostParse(virDomainDef *def,
unsigned int parseFlags,
void *opaque,
void *parseOpaque);
int
qemuDomainPostParseDataAlloc(const virDomainDef *def,
unsigned int parseFlags,
void *opaque,
void **parseOpaque);
void
qemuDomainPostParseDataFree(void *parseOpaque);

View File

@ -27,6 +27,7 @@
#include "qemu/qemu_monitor_json.h" #include "qemu/qemu_monitor_json.h"
#include "qemu/qemu_backup.h" #include "qemu/qemu_backup.h"
#include "qemu/qemu_checkpoint.h" #include "qemu/qemu_checkpoint.h"
#include "qemu/qemu_postparse.h"
#include "qemu/qemu_validate.h" #include "qemu/qemu_validate.h"
#define LIBVIRT_SNAPSHOT_CONF_PRIV_H_ALLOW #define LIBVIRT_SNAPSHOT_CONF_PRIV_H_ALLOW