On Tue, Feb 25, 2025 at 19:36:24 +0100, Roman Bogorodskiy wrote:
Alexander Shursha wrote:
> Signed-off-by: Alexander Shursha <kekek2(a)ya.ru>
> ---
> src/bhyve/bhyve_parse_command.c | 60 +++++++++++++++++++
> .../bhyveargv2xml-passthru.args | 7 +++
> .../bhyveargv2xml-passthru.xml | 22 +++++++
> tests/bhyveargv2xmltest.c | 1 +
> 4 files changed, 90 insertions(+)
> create mode 100644 tests/bhyveargv2xmldata/bhyveargv2xml-passthru.args
> create mode 100644 tests/bhyveargv2xmldata/bhyveargv2xml-passthru.xml
>
> diff --git a/src/bhyve/bhyve_parse_command.c b/src/bhyve/bhyve_parse_command.c
> index 29d3a678bf..394fc151aa 100644
> --- a/src/bhyve/bhyve_parse_command.c
> +++ b/src/bhyve/bhyve_parse_command.c
> @@ -5,6 +5,7 @@
> * Copyright (C) 2006 Daniel P. Berrange
> * Copyright (c) 2011 NetApp, Inc.
> * Copyright (C) 2020 Fabian Freyer
> + * Copyright (C) 2024-2025 Future Crew, LLC
> *
> * This library is free software; you can redistribute it and/or
> * modify it under the terms of the GNU Lesser General Public
> @@ -639,6 +640,63 @@ bhyveParsePCIFbuf(virDomainDef *def,
> return -1;
> }
>
> +static int
> +bhyveParsePassthru(virDomainDef *def G_GNUC_UNUSED,
> + unsigned pcibus,
> + unsigned pcislot,
> + unsigned pcifunction,
> + char *addr)
> +{
> + /* -s slot,bus/slot/function */
> + /* -s slot,pcibus:slot:function */
> + virDomainHostdevDef *hostdev = NULL;
> + g_auto(GStrv) params = NULL;
> + GStrv param;
> + char *p = NULL;
> +
> + hostdev = virDomainHostdevDefNew();
Need to check if hostdev is NULL.
That can't happen:
virDomainHostdevDef *
virDomainHostdevDefNew(void)
{
virDomainHostdevDef *def;
def = g_new0(virDomainHostdevDef, 1);
def->info = g_new0(virDomainDeviceInfo, 1);
return def;
}
g_new0() abort()'s on OOM, thus this is guaranteed to return a valid
pointer.