[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v8 01/21] softmmu: split off vl.c:main() into main.c
From: |
Alexander Bulekov |
Subject: |
Re: [PATCH v8 01/21] softmmu: split off vl.c:main() into main.c |
Date: |
Thu, 30 Jan 2020 12:44:01 -0500 |
User-agent: |
NeoMutt/20180716 |
On 200130 1506, Alex Bennée wrote:
>
> Bulekov, Alexander <address@hidden> writes:
>
> > A program might rely on functions implemented in vl.c, but implement its
> > own main(). By placing main into a separate source file, there are no
> > complaints about duplicate main()s when linking against vl.o. For
> > example, the virtual-device fuzzer uses a main() provided by libfuzzer,
> > and needs to perform some initialization before running the softmmu
> > initialization. Now, main simply calls three vl.c functions which
> > handle the guest initialization, main loop and cleanup.
> >
> > Signed-off-by: Alexander Bulekov <address@hidden>
> > ---
> <snip>
> > main.c | 53 +++++++++++++++++++++++++++++++++++++++++
> <snip>
> > --- a/Makefile.objs
> > +++ b/Makefile.objs
> > @@ -84,6 +84,8 @@ common-obj-$(CONFIG_FDT) += device_tree.o
> > # qapi
> >
> > common-obj-y += qapi/
> > +
> > +softmmu-obj-y = main.o
> > endif
> >
> <snip>
> > diff --git a/main.c b/main.c
> > new file mode 100644
> > index 0000000000..f10ceda541
> > --- /dev/null
> > +++ b/main.c
> > @@ -0,0 +1,53 @@
> > +/*
> > + * QEMU System Emulator
> > + *
> > + * Copyright (c) 2003-2008 Fabrice Bellard
> > + *
> > + * Permission is hereby granted, free of charge, to any person obtaining a
> > copy
> > + * of this software and associated documentation files (the "Software"),
> > to deal
> > + * in the Software without restriction, including without limitation the
> > rights
> > + * to use, copy, modify, merge, publish, distribute, sublicense, and/or
> > sell
> > + * copies of the Software, and to permit persons to whom the Software is
> > + * furnished to do so, subject to the following conditions:
> > + *
> > + * The above copyright notice and this permission notice shall be included
> > in
> > + * all copies or substantial portions of the Software.
> > + *
> > + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
> > OR
> > + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> > + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
> > + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
> > OTHER
> > + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
> > FROM,
> > + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
> > IN
> > + * THE SOFTWARE.
> > + */
> > +
> > +#include "qemu/osdep.h"
> > +#include "qemu-common.h"
> > +#include "sysemu/sysemu.h"
> > +
> > +#ifdef CONFIG_SDL
> > +#if defined(__APPLE__) || defined(main)
> > +#include <SDL.h>
> > +int main(int argc, char **argv)
> > +{
> > + return qemu_main(argc, argv, NULL);
> > +}
> > +#undef main
> > +#define main qemu_main
> > +#endif
> > +#endif /* CONFIG_SDL */
> > +
> > +#ifdef CONFIG_COCOA
> > +#undef main
> > +#define main qemu_main
> > +#endif /* CONFIG_COCOA */
> > +
> > +int main(int argc, char **argv, char **envp)
> > +{
> > + qemu_init(argc, argv, envp);
> > + qemu_main_loop();
> > + qemu_cleanup();
> > +
> > + return 0;
> > +}
> <snip>
>
> Can we put the main in a project appropriate sub-directory so it's on
> the same order as linux-user/main.c?
>
> I guess the new directory could be "softmmu" which matches the directory
> or "system" which matches the binary name. I'd lean towards the latter
> as softmmu is very specifically not this bit.
Will do - should vl.c move into this directory, as well?
-Alex
> --
> Alex Bennée
- [PATCH v8 00/21] Add virtual device fuzzing support, Bulekov, Alexander, 2020/01/29
- [PATCH v8 02/21] module: check module wasn't already initialized, Bulekov, Alexander, 2020/01/29
- [PATCH v8 03/21] fuzz: add FUZZ_TARGET module type, Bulekov, Alexander, 2020/01/29
- [PATCH v8 04/21] qtest: add qtest_server_send abstraction, Bulekov, Alexander, 2020/01/29
- [PATCH v8 05/21] libqtest: add a layer of abstraction to send/recv, Bulekov, Alexander, 2020/01/29
- [PATCH v8 06/21] libqtest: make bufwrite rely on the TransportOps, Bulekov, Alexander, 2020/01/29
- [PATCH v8 07/21] qtest: add in-process incoming command handler, Bulekov, Alexander, 2020/01/29
- [PATCH v8 08/21] libqos: rename i2c_send and i2c_recv, Bulekov, Alexander, 2020/01/29
- [PATCH v8 09/21] libqos: split qos-test and libqos makefile vars, Bulekov, Alexander, 2020/01/29
- [PATCH v8 12/21] exec: keep ram block across fork when using qtest, Bulekov, Alexander, 2020/01/29