diff --git a/bochs/iodev/hdimage/hdimage.cc b/bochs/iodev/hdimage/hdimage.cc index c5350767f..40c40d0f7 100644 --- a/bochs/iodev/hdimage/hdimage.cc +++ b/bochs/iodev/hdimage/hdimage.cc @@ -33,7 +33,7 @@ #include "cdrom_win32.h" #endif #include "hdimage.h" -#if !BX_PLUGINS || defined(BXIMAGE) +#ifdef BXIMAGE #include "vbox.h" #include "vmware3.h" #include "vmware4.h" @@ -292,6 +292,20 @@ hdimage_locator_c::create(const char *mode, Bit64u disk_size, const char *journa return NULL; } +bool hdimage_locator_c::detect_image_mode(int fd, Bit64u disk_size, + const char **image_mode) +{ + hdimage_locator_c *ptr = 0; + + for (ptr = all; ptr != NULL; ptr = ptr->next) { + if (ptr->check_format(fd, disk_size) == HDIMAGE_FORMAT_OK) { + *image_mode = ptr->mode; + return 1; + } + } + return 0; +} + #endif // ifndef BXIMAGE // helper functions @@ -440,7 +454,7 @@ bool hdimage_detect_image_mode(const char *pathname, const char **image_mode) } else if (growing_image_t::check_format(fd, image_size) == HDIMAGE_FORMAT_OK) { *image_mode = "growing"; result = true; -#if !BX_PLUGINS || defined(BXIMAGE) +#ifdef BXIMAGE } else if (vbox_image_t::check_format(fd, image_size) >= HDIMAGE_FORMAT_OK) { *image_mode = "vbox"; result = true; @@ -453,6 +467,9 @@ bool hdimage_detect_image_mode(const char *pathname, const char **image_mode) } else if (vpc_image_t::check_format(fd, image_size) >= HDIMAGE_FORMAT_OK) { *image_mode = "vpc"; result = true; +#else + } else if (hdimage_locator_c::detect_image_mode(fd, image_size, image_mode)) { + result = true; #endif } else if (flat_image_t::check_format(fd, image_size) == HDIMAGE_FORMAT_OK) { *image_mode = "flat"; diff --git a/bochs/iodev/hdimage/hdimage.h b/bochs/iodev/hdimage/hdimage.h index 65b810d16..dd806eb1c 100644 --- a/bochs/iodev/hdimage/hdimage.h +++ b/bochs/iodev/hdimage/hdimage.h @@ -628,10 +628,12 @@ public: static const char* get_module_name(Bit8u index); static void cleanup(void); static device_image_t *create(const char *mode, Bit64u disk_size, const char *journal); + static bool detect_image_mode(int fd, Bit64u disk_size, const char **image_mode); protected: hdimage_locator_c(const char *mode); virtual ~hdimage_locator_c(); virtual device_image_t *allocate(Bit64u disk_size, const char *journal) = 0; + virtual int check_format(int fd, Bit64u disk_size) {return -1;} private: static Bit8u count; static hdimage_locator_c *all; diff --git a/bochs/iodev/hdimage/vbox.cc b/bochs/iodev/hdimage/vbox.cc index 328da194e..1891a5b62 100644 --- a/bochs/iodev/hdimage/vbox.cc +++ b/bochs/iodev/hdimage/vbox.cc @@ -80,6 +80,9 @@ protected: device_image_t *allocate(Bit64u disk_size, const char *journal) { return (new vbox_image_t()); } + int check_format(int fd, Bit64u disk_size) { + return (vbox_image_t::check_format(fd, disk_size)); + } } bx_vbox_match; #endif diff --git a/bochs/iodev/hdimage/vmware3.cc b/bochs/iodev/hdimage/vmware3.cc index 516a7446d..470f27a14 100644 --- a/bochs/iodev/hdimage/vmware3.cc +++ b/bochs/iodev/hdimage/vmware3.cc @@ -75,6 +75,9 @@ protected: device_image_t *allocate(Bit64u disk_size, const char *journal) { return (new vmware3_image_t()); } + int check_format(int fd, Bit64u disk_size) { + return (vmware3_image_t::check_format(fd, disk_size)); + } } bx_vmware3_match; #endif diff --git a/bochs/iodev/hdimage/vmware4.cc b/bochs/iodev/hdimage/vmware4.cc index 8aa8d610c..75e1b6084 100644 --- a/bochs/iodev/hdimage/vmware4.cc +++ b/bochs/iodev/hdimage/vmware4.cc @@ -73,6 +73,9 @@ protected: device_image_t *allocate(Bit64u disk_size, const char *journal) { return (new vmware4_image_t()); } + int check_format(int fd, Bit64u disk_size) { + return (vmware4_image_t::check_format(fd, disk_size)); + } } bx_vmware4_match; #endif diff --git a/bochs/iodev/hdimage/vpc.cc b/bochs/iodev/hdimage/vpc.cc index c222e6f60..b1283bfa6 100644 --- a/bochs/iodev/hdimage/vpc.cc +++ b/bochs/iodev/hdimage/vpc.cc @@ -71,6 +71,9 @@ protected: device_image_t *allocate(Bit64u disk_size, const char *journal) { return (new vpc_image_t()); } + int check_format(int fd, Bit64u disk_size) { + return (vpc_image_t::check_format(fd, disk_size)); + } } bx_vpc_match; #endif diff --git a/bochs/plugin.cc b/bochs/plugin.cc index 958fa12b9..b5e3700fd 100644 --- a/bochs/plugin.cc +++ b/bochs/plugin.cc @@ -751,9 +751,8 @@ int bx_load_plugin(const char *name, plugintype_t type) if (!strcmp(name, "*")) { for (plugin = plugins; plugin; plugin = plugin->next) { - if (!strcmp(plugin->name, name) && (type == plugin->type) && - !plugin->loaded) { - plugin_load(name, type); + if ((type == plugin->type) && !plugin->loaded) { + plugin_load(plugin->name, type); } } } else {