On 10/10/23 23:42, Praveen K Paladugu wrote: > Starting with v28.0 cloud-hypervisor requires the use of "payload" api to pass > kernel, initramfs and cmdline options. Extend ch driver to use the new > api based on ch version. > > Signed-off-by: Praveen K Paladugu <prapal@xxxxxxxxxxxxxxxxxxx> > --- > src/ch/ch_capabilities.c | 55 ++++++++++++++++++++++++++++++++++++++++ > src/ch/ch_capabilities.h | 34 +++++++++++++++++++++++++ > src/ch/ch_conf.h | 6 +++++ > src/ch/ch_driver.c | 3 +++ > src/ch/ch_monitor.c | 48 +++++++++++++++++++++++++++++++---- > src/ch/ch_monitor.h | 4 ++- > src/ch/ch_process.c | 2 +- > src/ch/meson.build | 2 ++ > 8 files changed, 147 insertions(+), 7 deletions(-) > create mode 100644 src/ch/ch_capabilities.c > create mode 100644 src/ch/ch_capabilities.h > > diff --git a/src/ch/ch_capabilities.c b/src/ch/ch_capabilities.c > new file mode 100644 > index 0000000000..b10485820c > --- /dev/null > +++ b/src/ch/ch_capabilities.c > @@ -0,0 +1,55 @@ > +/* > + * Copyright Microsoft Corp. 2023 > + * > + * ch_capabilities.h: CH capabilities > + * > + * 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/>. > + */ > + > +#include <config.h> > +#include "ch_capabilities.h" > + > +static void > +virCHCapsSet(virBitmap *chCaps, > + virCHCapsFlags flag) > +{ > + ignore_value(virBitmapSetBit(chCaps, flag)); > +} > + > +/** > + * virCHCapsInitCHVersionCaps: > + * > + * Set all CH capabilities based on version of CH. > + */ > +virBitmap * > +virCHCapsInitCHVersionCaps(int version) > +{ > + g_autoptr(virBitmap) chCaps = NULL; > + chCaps = virBitmapNew(CH_CAPS_LAST); > + > + /* Version 28 deprecated kernel API: > + * https://github.com/cloud-hypervisor/cloud-hypervisor/releases/tag/v28.0 > + */ > + if (version >= 28000000) > + virCHCapsSet(chCaps, CH_KERNEL_API_DEPRCATED); > + > + > + /* Starting Version 18, serial and console can be used in parallel */ > + if (version >= 18000000) > + virCHCapsSet(chCaps, CH_SERIAL_CONSOLE_IN_PARALLEL); I wish there was a better way of checking for these facts. Historically, we used to parse 'qemu -help' output which is a bit better than just plain version check. OTOH, cloud hypervisor moves fast and probably doesn't suffer the same problems as qemu, i.e. a lot of backports (even features) with no version change. So I can live with this. Michal