From b2334879677f1014804fb93763210efb5e7a7ca6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn?= Date: Thu, 23 Jul 2015 12:44:17 +0200 Subject: [PATCH] Feature #1727: Make snapshot size a long long, to be the same as image size --- include/Snapshots.h | 6 +++--- src/image/Image.cc | 2 +- src/image/ImageManagerActions.cc | 2 +- src/image/ImageManagerDriver.cc | 12 ++++++------ src/vm/Snapshots.cc | 10 +++++----- src/vm/VirtualMachine.cc | 8 ++++---- 6 files changed, 20 insertions(+), 20 deletions(-) diff --git a/include/Snapshots.h b/include/Snapshots.h index 43d9d7d0e7..8eee27cd07 100644 --- a/include/Snapshots.h +++ b/include/Snapshots.h @@ -79,7 +79,7 @@ public: * @param size_mb of the snapshot (virtual size) * @return id of the new snapshot */ - int create_snapshot(const string& name, unsigned int size_mb); + int create_snapshot(const string& name, long long size_mb); /** * Check if an snapshot can be deleted (no children, no active) @@ -172,14 +172,14 @@ public: /** * @return total snapshot size (virtual) in mb */ - unsigned int get_total_size() const; + long long get_total_size() const; /** * Get the size (virtual) in mb of the given snapshot * @param id of the snapshot * @return size or 0 if not found */ - unsigned int get_snapshot_size(int id) const; + long long get_snapshot_size(int id) const; /** * Get Attribute from the given snapshot diff --git a/src/image/Image.cc b/src/image/Image.cc index 3db35b4f27..d8df6a1a2e 100644 --- a/src/image/Image.cc +++ b/src/image/Image.cc @@ -508,7 +508,7 @@ void Image::disk_attribute( VectorAttribute * disk, dev_prefix = disk->vector_value("DEV_PREFIX"); long long size = -1; - unsigned int snap_size; + long long snap_size; string template_target; string template_driver; diff --git a/src/image/ImageManagerActions.cc b/src/image/ImageManagerActions.cc index 74e421dcc9..30c2a932d1 100644 --- a/src/image/ImageManagerActions.cc +++ b/src/image/ImageManagerActions.cc @@ -498,7 +498,7 @@ int ImageManager::delete_image(int iid, string& error_str) ipool->update(img); } - unsigned int snap_size = (img->get_snapshots()).get_total_size(); + long long snap_size = (img->get_snapshots()).get_total_size(); img->unlock(); diff --git a/src/image/ImageManagerDriver.cc b/src/image/ImageManagerDriver.cc index 41bec760e8..d24de3f69e 100644 --- a/src/image/ImageManagerDriver.cc +++ b/src/image/ImageManagerDriver.cc @@ -693,8 +693,8 @@ static void snap_delete_action(istringstream& is, ostringstream oss; string info; - unsigned int snap_size; - int ds_id, uid, gid; + long long snap_size; + int ds_id, uid, gid; Image * image = ipool->get(id, true); @@ -753,7 +753,7 @@ static void snap_delete_action(istringstream& is, Template quotas; quotas.add("DATASTORE", ds_id); - quotas.add("SIZE", (long long) snap_size); + quotas.add("SIZE", snap_size); quotas.add("IMAGES",0 ); Quotas::ds_del(uid, gid, "as); @@ -828,8 +828,8 @@ static void snap_flatten_action(istringstream& is, ostringstream oss; string info; - unsigned int snap_size; - int ds_id, uid, gid; + long long snap_size; + int ds_id, uid, gid; Image * image = ipool->get(id, true); @@ -876,7 +876,7 @@ static void snap_flatten_action(istringstream& is, Template quotas; quotas.add("DATASTORE", ds_id); - quotas.add("SIZE", (long long) snap_size); + quotas.add("SIZE", snap_size); quotas.add("IMAGES",0 ); Quotas::ds_del(uid, gid, "as); diff --git a/src/vm/Snapshots.cc b/src/vm/Snapshots.cc index bc7c0e77b0..5cece0b2e2 100644 --- a/src/vm/Snapshots.cc +++ b/src/vm/Snapshots.cc @@ -122,7 +122,7 @@ void Snapshots::init() /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ -int Snapshots::create_snapshot(const string& name, unsigned int size_mb) +int Snapshots::create_snapshot(const string& name, long long size_mb) { VectorAttribute * snapshot = new VectorAttribute("SNAPSHOT"); @@ -285,9 +285,9 @@ string Snapshots::get_snapshot_attribute(int id, const char * name) const /* -------------------------------------------------------------------------- */ -unsigned int Snapshots::get_snapshot_size(int id) const +long long Snapshots::get_snapshot_size(int id) const { - unsigned int snap_size = 0; + long long snap_size = 0; const VectorAttribute * snapshot = get_snapshot(id); @@ -338,10 +338,10 @@ bool Snapshots::test_delete(int id, string& error) const /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ -unsigned int Snapshots::get_total_size() const +long long Snapshots::get_total_size() const { map::const_iterator it; - unsigned int size_mb, total_mb = 0; + long long size_mb, total_mb = 0; for ( it = snapshot_pool.begin(); it != snapshot_pool.end(); it++) { diff --git a/src/vm/VirtualMachine.cc b/src/vm/VirtualMachine.cc index 9006eae028..d482f1d3b8 100644 --- a/src/vm/VirtualMachine.cc +++ b/src/vm/VirtualMachine.cc @@ -4277,7 +4277,7 @@ int VirtualMachine::get_snapshot_disk(int& ds_id, string& tm_mad, int VirtualMachine::new_disk_snapshot(int did, const string& name, string& error) { map::iterator it; - unsigned int size_mb, snap_size; + long long size_mb, snap_size; int snap_id; VectorAttribute * disk; @@ -4391,7 +4391,7 @@ void VirtualMachine::delete_disk_snapshot(int did, int snap_id, Template **ds_quotas, Template **vm_quotas) { map::iterator it; - unsigned int snap_size; + long long snap_size; VectorAttribute * delta_disk; VectorAttribute * disk = get_disk(did); @@ -4411,7 +4411,7 @@ void VirtualMachine::delete_disk_snapshot(int did, int snap_id, return; } - unsigned int ssize = it->second->get_snapshot_size(snap_id); + long long ssize = it->second->get_snapshot_size(snap_id); it->second->delete_snapshot(snap_id); @@ -4433,7 +4433,7 @@ void VirtualMachine::delete_disk_snapshot(int did, int snap_id, *ds_quotas = new Template(); (*ds_quotas)->add("DATASTORE", disk->vector_value("DATASTORE_ID")); - (*ds_quotas)->add("SIZE", (long long) ssize); + (*ds_quotas)->add("SIZE", ssize); (*ds_quotas)->add("IMAGES",0 ); }