Richard W.M. Jones
2017-May-02 13:35 UTC
[Libguestfs] [PATCH v2] launch: Error if you try to launch with too many drives.
v1 was here: https://www.redhat.com/archives/libguestfs/2017-April/msg00268.html v1 broke some tests because the guestfs_max_disks API isn't supported by some backends, specifically ?unix:?. This makes failure of guestfs_max_disks non-fatal. Rich.
Richard W.M. Jones
2017-May-02 13:35 UTC
[Libguestfs] [PATCH v2] launch: Error if you try to launch with too many drives.
In particular the virt-rescue --scratch option makes it very easy to add huge numbers of drives. Since the per-backend max_disks limit was never checked anywhere you could get peculiar failures. Now you'll get a clear error message: $ virt-rescue --scratch=256 libguestfs: error: too many drives have been added, the current backend only supports 255 drives --- lib/launch.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/lib/launch.c b/lib/launch.c index 7f06c69..37ab024 100644 --- a/lib/launch.c +++ b/lib/launch.c @@ -55,12 +55,27 @@ static struct backend { int guestfs_impl_launch (guestfs_h *g) { + int r; + /* Configured? */ if (g->state != CONFIG) { error (g, _("the libguestfs handle has already been launched")); return -1; } + /* Too many drives? + * + * Some backends such as ?unix:? don't allow us to query max_disks. + * Don't fail in this case. + */ + guestfs_push_error_handler (g, NULL, NULL); + r = guestfs_max_disks (g); + guestfs_pop_error_handler (g); + if (r >= 0 && g->nr_drives > (size_t) r) { + error (g, _("too many drives have been added, the current backend only supports %d drives"), r); + return -1; + } + /* Start the clock ... */ gettimeofday (&g->launch_t, NULL); TRACE0 (launch_start); -- 2.9.3
Pino Toscano
2017-May-05 11:44 UTC
Re: [Libguestfs] [PATCH v2] launch: Error if you try to launch with too many drives.
On Tuesday, 2 May 2017 15:35:53 CEST Richard W.M. Jones wrote:> In particular the virt-rescue --scratch option makes it very easy to > add huge numbers of drives. Since the per-backend max_disks limit was > never checked anywhere you could get peculiar failures. Now you'll > get a clear error message: > > $ virt-rescue --scratch=256 > libguestfs: error: too many drives have been added, the current backend only supports 255 drives > ---Not wrong per-se, although IMHO it could just query g->backend_ops->max_disks with no need to go throught the tracing/wrapping API stuff. -- Pino Toscano
Maybe Matching Threads
- [PATCH v2] launch: Error if you try to launch with too many drives.
- [PATCH] launch: Error if you try to launch with too many drives.
- [PATCH v2 0/4] Experimental User-Mode Linux backend.
- [PATCH 0/4] Not quite working User-Mode Linux backend.
- [PATCH v4 0/5] Finish hotplugging support.